diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-28 10:33:09 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-29 08:51:48 +0200 |
commit | 1ffba0e356608fb6dbf568248e2a953b4d7fb5d6 (patch) | |
tree | 5da59640441292421f2137bc85ee7291daed137e /framework/source/tabwin/tabwindow.cxx | |
parent | ce9a41dc387966c74c1af92783a97565b5af3668 (diff) |
loplugin:flatten check for throw in then clause
also make the plugin ignore the case where we have var decl's in the
clause we want to flatten, which could lead to problematic extension of
variable lifetime
Change-Id: I3061f7104e8c6a460bf74f5eac325a516ec50c59
Reviewed-on: https://gerrit.libreoffice.org/42889
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework/source/tabwin/tabwindow.cxx')
-rw-r--r-- | framework/source/tabwin/tabwindow.cxx | 92 |
1 files changed, 43 insertions, 49 deletions
diff --git a/framework/source/tabwin/tabwindow.cxx b/framework/source/tabwin/tabwindow.cxx index 9070ce850ca8..606f13748517 100644 --- a/framework/source/tabwin/tabwindow.cxx +++ b/framework/source/tabwin/tabwindow.cxx @@ -619,34 +619,32 @@ void SAL_CALL TabWindow::setTabProps( ::sal_Int32 ID, const css::uno::Sequence< sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); if ( nPos == TAB_PAGE_NOTFOUND ) throw css::lang::IndexOutOfBoundsException(); - else - { - comphelper::SequenceAsHashMap aSeqHashMap( Properties ); - - OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); - sal_Int32 nNewPos = nPos; - aTitle = aSeqHashMap.getUnpackedValueOrDefault< OUString >( - m_aTitlePropName, aTitle ); - pTabControl->SetPageText( sal_uInt16( ID ), aTitle ); - nNewPos = aSeqHashMap.getUnpackedValueOrDefault< sal_Int32 >( - m_aPosPropName, nNewPos ); - if ( nNewPos != sal_Int32( nPos )) - { - nPos = sal_uInt16( nNewPos ); - if ( nPos >= pTabControl->GetPageCount() ) - nPos = TAB_APPEND; + comphelper::SequenceAsHashMap aSeqHashMap( Properties ); - pTabControl->RemovePage( sal_uInt16( ID )); - pTabControl->InsertPage( sal_uInt16( ID ), aTitle, nPos ); - } + OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); + sal_Int32 nNewPos = nPos; - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - aLock.clear(); + aTitle = aSeqHashMap.getUnpackedValueOrDefault< OUString >( + m_aTitlePropName, aTitle ); + pTabControl->SetPageText( sal_uInt16( ID ), aTitle ); + nNewPos = aSeqHashMap.getUnpackedValueOrDefault< sal_Int32 >( + m_aPosPropName, nNewPos ); + if ( nNewPos != sal_Int32( nPos )) + { + nPos = sal_uInt16( nNewPos ); + if ( nPos >= pTabControl->GetPageCount() ) + nPos = TAB_APPEND; - css::uno::Sequence< css::beans::NamedValue > aNamedValueSeq = getTabProps( ID ); - implts_SendNotification( NOTIFY_CHANGED, ID, aNamedValueSeq ); + pTabControl->RemovePage( sal_uInt16( ID )); + pTabControl->InsertPage( sal_uInt16( ID ), aTitle, nPos ); } + + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + aLock.clear(); + + css::uno::Sequence< css::beans::NamedValue > aNamedValueSeq = getTabProps( ID ); + implts_SendNotification( NOTIFY_CHANGED, ID, aNamedValueSeq ); } } @@ -665,18 +663,16 @@ css::uno::Sequence< css::beans::NamedValue > SAL_CALL TabWindow::getTabProps( :: sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); if ( nPos == TAB_PAGE_NOTFOUND ) throw css::lang::IndexOutOfBoundsException(); - else - { - OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); - nPos = pTabControl->GetPagePos( sal_uInt16( ID )); - css::uno::Sequence< css::beans::NamedValue > aSeq - { - { m_aTitlePropName, css::uno::makeAny( aTitle ) }, - { m_aPosPropName, css::uno::makeAny( sal_Int32( nPos )) } - }; - return aSeq; - } + OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); + nPos = pTabControl->GetPagePos( sal_uInt16( ID )); + + css::uno::Sequence< css::beans::NamedValue > aSeq + { + { m_aTitlePropName, css::uno::makeAny( aTitle ) }, + { m_aPosPropName, css::uno::makeAny( sal_Int32( nPos )) } + }; + return aSeq; } return aNamedValueSeq; @@ -696,21 +692,19 @@ void SAL_CALL TabWindow::activateTab( ::sal_Int32 ID ) sal_uInt16 nPos = pTabControl->GetPagePos( sal_uInt16( ID )); if ( nPos == TAB_PAGE_NOTFOUND ) throw css::lang::IndexOutOfBoundsException(); - else - { - sal_Int32 nOldID = pTabControl->GetCurPageId(); - OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); - pTabControl->SetCurPageId( sal_uInt16( ID )); - pTabControl->SelectTabPage( sal_uInt16( ID )); - impl_SetTitle( aTitle ); - - aLock.clear(); - /* SAFE AREA ----------------------------------------------------------------------------------------------- */ - - if ( nOldID != TAB_PAGE_NOTFOUND ) - implts_SendNotification( NOTIFY_DEACTIVATED, nOldID ); - implts_SendNotification( NOTIFY_ACTIVATED, ID ); - } + + sal_Int32 nOldID = pTabControl->GetCurPageId(); + OUString aTitle = pTabControl->GetPageText( sal_uInt16( ID )); + pTabControl->SetCurPageId( sal_uInt16( ID )); + pTabControl->SelectTabPage( sal_uInt16( ID )); + impl_SetTitle( aTitle ); + + aLock.clear(); + /* SAFE AREA ----------------------------------------------------------------------------------------------- */ + + if ( nOldID != TAB_PAGE_NOTFOUND ) + implts_SendNotification( NOTIFY_DEACTIVATED, nOldID ); + implts_SendNotification( NOTIFY_ACTIVATED, ID ); } } |