diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-18 11:54:34 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-10-19 07:57:49 +0200 |
commit | 265072a4cafd9f8552264448e2fc049ae3ac97e5 (patch) | |
tree | effa65b8c43bedee6493da446840f3114fd2d77f /vcl | |
parent | a22d32644be3fede66558df997e4c75ed96b2fa8 (diff) |
loplugin:staticvar in vcl
Change-Id: I2bdab84dc81e0545aa96542caec213db61765f68
Reviewed-on: https://gerrit.libreoffice.org/61922
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/svapp.cxx | 86 | ||||
-rw-r--r-- | vcl/source/font/font.cxx | 6 | ||||
-rw-r--r-- | vcl/source/fontsubset/ttcr.cxx | 4 | ||||
-rw-r--r-- | vcl/source/window/debugevent.cxx | 6 | ||||
-rw-r--r-- | vcl/source/window/layout.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/app/i18n_ic.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/generic/app/saldisp.cxx | 17 | ||||
-rw-r--r-- | vcl/unx/generic/fontmanager/fontmanager.cxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 2 | ||||
-rw-r--r-- | vcl/workben/vcldemo.cxx | 12 |
10 files changed, 53 insertions, 86 deletions
diff --git a/vcl/source/app/svapp.cxx b/vcl/source/app/svapp.cxx index a43b830ded2b..fb8ec12d28d7 100644 --- a/vcl/source/app/svapp.cxx +++ b/vcl/source/app/svapp.cxx @@ -89,65 +89,35 @@ void InitSettings(ImplSVData* pSVData); } // keycodes handled internally by VCL -class ImplReservedKey -{ -public: - explicit ImplReservedKey( vcl::KeyCode aKeyCode ) - : mKeyCode(aKeyCode) - { - } - - vcl::KeyCode mKeyCode; -}; - -typedef std::pair<ImplReservedKey*, size_t> ReservedKeys; -namespace -{ - struct ImplReservedKeysImpl - { - ReservedKeys* operator()() - { - static ImplReservedKey ImplReservedKeys[] = - { - ImplReservedKey(vcl::KeyCode(KEY_F1,0) ), - ImplReservedKey(vcl::KeyCode(KEY_F1,KEY_SHIFT) ), - ImplReservedKey(vcl::KeyCode(KEY_F1,KEY_MOD1) ), - ImplReservedKey(vcl::KeyCode(KEY_F2,KEY_SHIFT) ), - ImplReservedKey(vcl::KeyCode(KEY_F4,KEY_MOD1) ), - ImplReservedKey(vcl::KeyCode(KEY_F4,KEY_MOD2) ), - ImplReservedKey(vcl::KeyCode(KEY_F4,KEY_MOD1|KEY_MOD2) ), - ImplReservedKey(vcl::KeyCode(KEY_F6,0) ), - ImplReservedKey(vcl::KeyCode(KEY_F6,KEY_MOD1) ), - ImplReservedKey(vcl::KeyCode(KEY_F6,KEY_SHIFT) ), - ImplReservedKey(vcl::KeyCode(KEY_F6,KEY_MOD1|KEY_SHIFT) ), - ImplReservedKey(vcl::KeyCode(KEY_F10,0) ) +static vcl::KeyCode const ReservedKeys[] +{ + vcl::KeyCode(KEY_F1,0) , + vcl::KeyCode(KEY_F1,KEY_SHIFT) , + vcl::KeyCode(KEY_F1,KEY_MOD1) , + vcl::KeyCode(KEY_F2,KEY_SHIFT) , + vcl::KeyCode(KEY_F4,KEY_MOD1) , + vcl::KeyCode(KEY_F4,KEY_MOD2) , + vcl::KeyCode(KEY_F4,KEY_MOD1|KEY_MOD2) , + vcl::KeyCode(KEY_F6,0) , + vcl::KeyCode(KEY_F6,KEY_MOD1) , + vcl::KeyCode(KEY_F6,KEY_SHIFT) , + vcl::KeyCode(KEY_F6,KEY_MOD1|KEY_SHIFT) , + vcl::KeyCode(KEY_F10,0) #ifdef UNX , - ImplReservedKey(vcl::KeyCode(KEY_1,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_2,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_3,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_4,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_5,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_6,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_7,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_8,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_9,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_0,KEY_SHIFT|KEY_MOD1)), - ImplReservedKey(vcl::KeyCode(KEY_ADD,KEY_SHIFT|KEY_MOD1)) + vcl::KeyCode(KEY_1,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_2,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_3,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_4,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_5,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_6,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_7,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_8,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_9,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_0,KEY_SHIFT|KEY_MOD1), + vcl::KeyCode(KEY_ADD,KEY_SHIFT|KEY_MOD1) #endif - }; - static ReservedKeys aKeys - ( - &ImplReservedKeys[0], - SAL_N_ELEMENTS(ImplReservedKeys) - ); - return &aKeys; - } - }; - - struct ImplReservedKeys - : public rtl::StaticAggregate<ReservedKeys, ImplReservedKeysImpl> {}; -} +}; extern "C" { typedef UnoWrapperBase* (*FN_TkCreateUnoWrapper)(); @@ -298,7 +268,7 @@ void Application::Abort( const OUString& rErrorText ) sal_uLong Application::GetReservedKeyCodeCount() { - return ImplReservedKeys::get()->second; + return SAL_N_ELEMENTS(ReservedKeys); } const vcl::KeyCode* Application::GetReservedKeyCode( sal_uLong i ) @@ -306,7 +276,7 @@ const vcl::KeyCode* Application::GetReservedKeyCode( sal_uLong i ) if( i >= GetReservedKeyCodeCount() ) return nullptr; else - return &ImplReservedKeys::get()->first[i].mKeyCode; + return &ReservedKeys[i]; } IMPL_STATIC_LINK_NOARG( ImplSVAppData, ImplEndAllPopupsMsg, void*, void ) diff --git a/vcl/source/font/font.cxx b/vcl/source/font/font.cxx index e8981996e09a..1cf88d394175 100644 --- a/vcl/source/font/font.cxx +++ b/vcl/source/font/font.cxx @@ -532,7 +532,7 @@ namespace return bResult; } - struct WeightSearchEntry + static struct WeightSearchEntry { const char* string; int string_len; @@ -543,7 +543,7 @@ namespace return rtl_str_compareIgnoreAsciiCase_WithLength( string, string_len, rRight.string, rRight.string_len ) < 0; } } - weight_table[] = + const weight_table[] = { { "black", 5, WEIGHT_BLACK }, { "bold", 4, WEIGHT_BOLD }, @@ -611,7 +611,7 @@ namespace aEnt.string_len = (pClose-pOpen)-1; aEnt.weight = WEIGHT_NORMAL; const int nEnt = SAL_N_ELEMENTS( weight_table ); - WeightSearchEntry* pFound = std::lower_bound( weight_table, weight_table+nEnt, aEnt ); + WeightSearchEntry const * pFound = std::lower_bound( weight_table, weight_table+nEnt, aEnt ); if( pFound != (weight_table+nEnt) ) o_rResult.SetWeight( pFound->weight ); } diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx index 4dc5084e6128..06bbe376f3a4 100644 --- a/vcl/source/fontsubset/ttcr.cxx +++ b/vcl/source/fontsubset/ttcr.cxx @@ -479,7 +479,7 @@ static void TrueTypeTableDispose_post(TrueTypeTable *_this) static struct { sal_uInt32 tag; void (*f)(TrueTypeTable *); -} vtable1[] = +} const vtable1[] = { {0, TrueTypeTableDispose_generic}, {T_head, TrueTypeTableDispose_head}, @@ -800,7 +800,7 @@ static int GetRawData_post(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le static struct { sal_uInt32 tag; int (*f)(TrueTypeTable *, sal_uInt8 **, sal_uInt32 *, sal_uInt32 *); -} vtable2[] = +} const vtable2[] = { {0, GetRawData_generic}, {T_head, GetRawData_head}, diff --git a/vcl/source/window/debugevent.cxx b/vcl/source/window/debugevent.cxx index 01459201dcdc..d7d5ec182f14 100644 --- a/vcl/source/window/debugevent.cxx +++ b/vcl/source/window/debugevent.cxx @@ -137,10 +137,10 @@ void DebugEventInjector::InjectTextEvent() } else { - struct { + static struct { sal_uInt16 nCodeStart, nCodeEnd; char const aCharStart; - } nTextCodes[] = { + } const nTextCodes[] = { { KEY_0, KEY_9, '0' }, { KEY_A, KEY_Z, 'a' } }; @@ -191,7 +191,7 @@ void DebugEventInjector::InjectKeyNavEdit() { vcl::Window *pWindow = ChooseWindow(); - struct { + static struct { double const mnProb; sal_uInt16 const mnKey; } const nWeights[] = { diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx index d1a539acea09..10f28daa6a6f 100644 --- a/vcl/source/window/layout.cxx +++ b/vcl/source/window/layout.cxx @@ -824,7 +824,7 @@ void VclButtonBox::setAllocation(const Size &rAllocation) struct ButtonOrder { - OString const m_aType; + const char* m_aType; int const m_nPriority; }; diff --git a/vcl/unx/generic/app/i18n_ic.cxx b/vcl/unx/generic/app/i18n_ic.cxx index 87c84b5c44ef..ad7f408748b2 100644 --- a/vcl/unx/generic/app/i18n_ic.cxx +++ b/vcl/unx/generic/app/i18n_ic.cxx @@ -443,7 +443,7 @@ SalI18N_InputContext::GetWeightingOfIMStyle( XIMStyle nStyle ) }; StyleWeightingT const *pWeightPtr; - const StyleWeightingT pWeight[] = { + static const StyleWeightingT pWeight[] = { { XIMPreeditCallbacks, 0x10000000 }, { XIMPreeditPosition, 0x02000000 }, { XIMPreeditArea, 0x01000000 }, diff --git a/vcl/unx/generic/app/saldisp.cxx b/vcl/unx/generic/app/saldisp.cxx index dbe1995f5150..e454587bafe0 100644 --- a/vcl/unx/generic/app/saldisp.cxx +++ b/vcl/unx/generic/app/saldisp.cxx @@ -158,24 +158,21 @@ extern "C" srv_vendor_t sal_GetServerVendor( Display *p_display ) { typedef struct { - srv_vendor_t const e_vendor; // vendor as enum - const char *p_name; // vendor name as returned by VendorString() - unsigned int const n_len; // number of chars to compare + srv_vendor_t e_vendor; // vendor as enum + const char* p_name; // vendor name as returned by VendorString() + unsigned int n_len; // number of chars to compare } vendor_t; - const vendor_t p_vendorlist[] = { + static const vendor_t vendorlist[] = { { vendor_sun, "Sun Microsystems, Inc.", 10 }, - // always the last entry: vendor_none to indicate eol - { vendor_none, nullptr, 0 }, }; // handle regular server vendors char *p_name = ServerVendor( p_display ); - vendor_t *p_vendor; - for (p_vendor = const_cast<vendor_t*>(p_vendorlist); p_vendor->e_vendor != vendor_none; p_vendor++) + for (auto const & vendor : vendorlist) { - if ( strncmp (p_name, p_vendor->p_name, p_vendor->n_len) == 0 ) - return p_vendor->e_vendor; + if ( strncmp (p_name, vendor.p_name, vendor.n_len) == 0 ) + return vendor.e_vendor; } // vendor not found in list diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx index 06ee4f180b1b..394c5484a5bd 100644 --- a/vcl/unx/generic/fontmanager/fontmanager.cxx +++ b/vcl/unx/generic/fontmanager/fontmanager.cxx @@ -847,7 +847,7 @@ FontFamily PrintFontManager::matchFamilyName( const OUString& rFamily ) } family_t; #define InitializeClass( p, a ) p, sizeof(p) - 1, a - const family_t pFamilyMatch[] = { + static const family_t pFamilyMatch[] = { { InitializeClass( "arial", FAMILY_SWISS ) }, { InitializeClass( "arioso", FAMILY_SCRIPT ) }, { InitializeClass( "avant garde", FAMILY_SWISS ) }, diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 1141e408be4e..f43d6dc46da4 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2094,7 +2094,7 @@ namespace { struct ButtonOrder { - OString m_aType; + const char * m_aType; int m_nPriority; }; diff --git a/vcl/workben/vcldemo.cxx b/vcl/workben/vcldemo.cxx index 6b2db288d87d..9c83df9ce3b2 100644 --- a/vcl/workben/vcldemo.cxx +++ b/vcl/workben/vcldemo.cxx @@ -350,11 +350,11 @@ public: tools::Rectangle aBottom(aToplevelRegions[1].TopLeft(), aToplevelRegions[2].BottomRight()); DemoRenderer::clearRects(rDev,aSubRegions); - struct { + static struct { bool const mbClip; bool const mbArabicText; bool const mbRotate; - } aRenderData[] = { + } const aRenderData[] = { { false, false, false }, { false, true, false }, { false, true, true }, @@ -518,10 +518,10 @@ public: 0xf0, 0x9f, 0x82, 0xa1, 0xc2, 0xa2, 0xc2, 0xa2, 0 }; - struct { + static struct { const char *mpFont; const char *mpString; - } aRuns[] = { + } const aRuns[] = { #define SET(font,string) { font, reinterpret_cast<const char *>(string) } SET("sans", "a"), // logical font - no 'sans' font. SET("opensymbol", "#$%"), // font fallback - $ is missing. @@ -927,9 +927,9 @@ public: virtual void RenderRegion(OutputDevice &rDev, tools::Rectangle r, const RenderContext &) override { - struct { + static struct { double nX, nY; - } aPoints[] = { { 0.1, 0.1 }, { 0.9, 0.9 }, + } const aPoints[] = { { 0.1, 0.1 }, { 0.9, 0.9 }, #if FIXME_SELF_INTERSECTING_WORKING { 0.9, 0.1 }, { 0.1, 0.9 }, { 0.1, 0.1 } |