diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2018-02-20 16:03:20 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2018-02-21 08:09:46 +0100 |
commit | ba8a70365ef459c967cd8a71a6d48ca53dd341bd (patch) | |
tree | 397ae034cac2f06ea40ed550a7ce39cf4a42966e /toolkit | |
parent | 0adb36835bcbe55bdf2717556a98e51f1873b19f (diff) |
New loplugin:nestedunnamed
Change-Id: Ifb434589ef08428ce609bc7a40b015d4df13224c
Reviewed-on: https://gerrit.libreoffice.org/50048
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'toolkit')
-rw-r--r-- | toolkit/source/awt/vclxtoolkit.cxx | 62 | ||||
-rw-r--r-- | toolkit/source/controls/animatedimages.cxx | 17 | ||||
-rw-r--r-- | toolkit/source/controls/grid/sortablegriddatamodel.cxx | 116 |
3 files changed, 84 insertions, 111 deletions
diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 2dc9dd02eccb..90d7ce2ce2ec 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -544,46 +544,42 @@ WindowType ImplGetComponentType( const OUString& rServiceName ) return pInf ? pInf->nWinType : WindowType::NONE; } +struct MessageBoxTypeInfo +{ + css::awt::MessageBoxType eType; + const sal_Char *pName; + sal_Int32 nLen; +}; -namespace +static const MessageBoxTypeInfo aMessageBoxTypeInfo[] = { - struct MessageBoxTypeInfo - { - css::awt::MessageBoxType eType; - const sal_Char *pName; - sal_Int32 nLen; - }; + { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, + { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, + { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, + { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, + { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, + { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } +}; - static const MessageBoxTypeInfo aMessageBoxTypeInfo[] = - { - { css::awt::MessageBoxType_MESSAGEBOX, RTL_CONSTASCII_STRINGPARAM("messbox") }, - { css::awt::MessageBoxType_INFOBOX, RTL_CONSTASCII_STRINGPARAM("infobox") }, - { css::awt::MessageBoxType_WARNINGBOX, RTL_CONSTASCII_STRINGPARAM("warningbox") }, - { css::awt::MessageBoxType_ERRORBOX, RTL_CONSTASCII_STRINGPARAM("errorbox") }, - { css::awt::MessageBoxType_QUERYBOX, RTL_CONSTASCII_STRINGPARAM("querybox") }, - { css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE, nullptr, 0 } - }; - - bool lcl_convertMessageBoxType( - rtl::OUString &sType, - css::awt::MessageBoxType eType ) - { - const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; - css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; +bool lcl_convertMessageBoxType( + rtl::OUString &sType, + css::awt::MessageBoxType eType ) +{ + const MessageBoxTypeInfo *pMap = aMessageBoxTypeInfo; + css::awt::MessageBoxType eVal = css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE; - while ( pMap->pName ) + while ( pMap->pName ) + { + if ( pMap->eType == eType ) { - if ( pMap->eType == eType ) - { - eVal = eType; - sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); - break; - } - pMap++; + eVal = eType; + sType = rtl::OUString( pMap->pName, pMap->nLen, RTL_TEXTENCODING_ASCII_US ); + break; } - - return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); + pMap++; } + + return ( eVal != css::awt::MessageBoxType::MessageBoxType_MAKE_FIXED_SIZE ); } static sal_Int32 nVCLToolkitInstanceCount = 0; diff --git a/toolkit/source/controls/animatedimages.cxx b/toolkit/source/controls/animatedimages.cxx index 4d8f55f8ff6e..3e29b67cb01e 100644 --- a/toolkit/source/controls/animatedimages.cxx +++ b/toolkit/source/controls/animatedimages.cxx @@ -131,22 +131,17 @@ public: return aServices; } - - namespace + void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) { - void lcl_updatePeer( Reference< XWindowPeer > const& i_peer, Reference< XControlModel > const& i_model ) + const Reference< css::util::XModifyListener > xPeerModify( i_peer, UNO_QUERY ); + if ( xPeerModify.is() ) { - const Reference< css::util::XModifyListener > xPeerModify( i_peer, UNO_QUERY ); - if ( xPeerModify.is() ) - { - EventObject aEvent; - aEvent.Source = i_model; - xPeerModify->modified( aEvent ); - } + EventObject aEvent; + aEvent.Source = i_model; + xPeerModify->modified( aEvent ); } } - sal_Bool SAL_CALL AnimatedImagesControl::setModel( const Reference< XControlModel >& i_rModel ) { const Reference< XAnimatedImages > xOldContainer( getModel(), UNO_QUERY ); diff --git a/toolkit/source/controls/grid/sortablegriddatamodel.cxx b/toolkit/source/controls/grid/sortablegriddatamodel.cxx index e9cafb05b6d8..f81aefd734fd 100644 --- a/toolkit/source/controls/grid/sortablegriddatamodel.cxx +++ b/toolkit/source/controls/grid/sortablegriddatamodel.cxx @@ -209,15 +209,12 @@ public: } }; - namespace - { - template< class STLCONTAINER > - void lcl_clear( STLCONTAINER& i_container ) - { - STLCONTAINER empty; - empty.swap( i_container ); - } - } +template< class STLCONTAINER > +void lcl_clear( STLCONTAINER& i_container ) +{ + STLCONTAINER empty; + empty.swap( i_container ); +} SortableGridDataModel::SortableGridDataModel( Reference< XComponentContext > const & rxContext ) :SortableGridDataModel_Base( m_aMutex ) @@ -296,18 +293,13 @@ public: return css::uno::Sequence<sal_Int8>(); } - - namespace + Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference<XComponentContext> & rxContext ) { - Reference< XCollator > lcl_loadDefaultCollator_throw( const Reference<XComponentContext> & rxContext ) - { - Reference< XCollator > const xCollator = Collator::create( rxContext ); - xCollator->loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 ); - return xCollator; - } + Reference< XCollator > const xCollator = Collator::create( rxContext ); + xCollator->loadDefaultCollator( Application::GetSettings().GetLanguageTag().getLocale(), 0 ); + return xCollator; } - void SAL_CALL SortableGridDataModel::initialize( const Sequence< Any >& i_arguments ) { ::comphelper::ComponentGuard aGuard( *this, rBHelper ); @@ -381,23 +373,18 @@ public: impl_broadcast( &XGridDataListener::rowsInserted, aEvent, aGuard ); } - - namespace + void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) { - void lcl_decrementValuesGreaterThan( ::std::vector< ::sal_Int32 > & io_indexMap, sal_Int32 const i_threshold ) + for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); + loop != io_indexMap.end(); + ++loop + ) { - for ( ::std::vector< ::sal_Int32 >::iterator loop = io_indexMap.begin(); - loop != io_indexMap.end(); - ++loop - ) - { - if ( *loop >= i_threshold ) - --*loop; - } + if ( *loop >= i_threshold ) + --*loop; } } - void SortableGridDataModel::impl_rebuildIndexesAndNotify( MethodGuard& i_instanceLock ) { OSL_PRECOND( impl_isSorted_nothrow(), "SortableGridDataModel::impl_rebuildIndexesAndNotify: illegal call!" ); @@ -506,47 +493,42 @@ public: { } - - namespace + class CellDataLessComparison { - class CellDataLessComparison + public: + CellDataLessComparison( + ::std::vector< Any > const & i_data, + ::comphelper::IKeyPredicateLess const & i_predicate, + bool const i_sortAscending + ) + :m_data( i_data ) + ,m_predicate( i_predicate ) + ,m_sortAscending( i_sortAscending ) { - public: - CellDataLessComparison( - ::std::vector< Any > const & i_data, - ::comphelper::IKeyPredicateLess const & i_predicate, - bool const i_sortAscending - ) - :m_data( i_data ) - ,m_predicate( i_predicate ) - ,m_sortAscending( i_sortAscending ) - { - } - - bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const - { - Any const & lhs = m_data[ i_lhs ]; - Any const & rhs = m_data[ i_rhs ]; - // <VOID/> is less than everything else - if ( !lhs.hasValue() ) - return m_sortAscending; - if ( !rhs.hasValue() ) - return !m_sortAscending; - - // actually compare - if ( m_sortAscending ) - return m_predicate.isLess( lhs, rhs ); - else - return m_predicate.isLess( rhs, lhs ); - } + } - private: - ::std::vector< Any > const & m_data; - ::comphelper::IKeyPredicateLess const & m_predicate; - bool const m_sortAscending; - }; - } + bool operator()( sal_Int32 const i_lhs, sal_Int32 const i_rhs ) const + { + Any const & lhs = m_data[ i_lhs ]; + Any const & rhs = m_data[ i_rhs ]; + // <VOID/> is less than everything else + if ( !lhs.hasValue() ) + return m_sortAscending; + if ( !rhs.hasValue() ) + return !m_sortAscending; + + // actually compare + if ( m_sortAscending ) + return m_predicate.isLess( lhs, rhs ); + else + return m_predicate.isLess( rhs, lhs ); + } + private: + ::std::vector< Any > const & m_data; + ::comphelper::IKeyPredicateLess const & m_predicate; + bool const m_sortAscending; + }; bool SortableGridDataModel::impl_reIndex_nothrow( ::sal_Int32 const i_columnIndex, bool const i_sortAscending ) { |