diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-21 11:06:43 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-21 15:29:20 +0200 |
commit | 3a481dde031ba416ec4ef0351130e26e49417418 (patch) | |
tree | abfec5320c66e8c28b3da01852c531ef4a7ce0eb /editeng/source/accessibility | |
parent | ac80f048f2bb23651ddc3c6608e9ef24635698d7 (diff) |
loplugin:flatten in editeng..extensions
Change-Id: I2b68f5640471ea827c09af1b5a319fb526a53b4b
Reviewed-on: https://gerrit.libreoffice.org/42579
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'editeng/source/accessibility')
-rw-r--r-- | editeng/source/accessibility/AccessibleEditableTextPara.cxx | 51 | ||||
-rw-r--r-- | editeng/source/accessibility/AccessibleImageBullet.cxx | 15 |
2 files changed, 28 insertions, 38 deletions
diff --git a/editeng/source/accessibility/AccessibleEditableTextPara.cxx b/editeng/source/accessibility/AccessibleEditableTextPara.cxx index c35a2dc05343..04eed5cd5996 100644 --- a/editeng/source/accessibility/AccessibleEditableTextPara.cxx +++ b/editeng/source/accessibility/AccessibleEditableTextPara.cxx @@ -434,13 +434,12 @@ namespace accessibility SvxEditSourceAdapter& AccessibleEditableTextPara::GetEditSource() const { - if( mpEditSource ) - return *mpEditSource; - else + if( !mpEditSource ) throw uno::RuntimeException("No edit source, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + return *mpEditSource; } SvxAccessibleTextAdapter& AccessibleEditableTextPara::GetTextForwarder() const @@ -454,13 +453,12 @@ namespace accessibility ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy - if( pTextForwarder->IsValid() ) - return *pTextForwarder; - else + if( !pTextForwarder->IsValid() ) throw uno::RuntimeException("Text forwarder is invalid, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + return *pTextForwarder; } SvxViewForwarder& AccessibleEditableTextPara::GetViewForwarder() const @@ -476,13 +474,12 @@ namespace accessibility ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy } - if( pViewForwarder->IsValid() ) - return *pViewForwarder; - else + if( !pViewForwarder->IsValid() ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleEditableTextPara* > (this) ) ) ); // disambiguate hierarchy + return *pViewForwarder; } SvxAccessibleTextEditViewAdapter& AccessibleEditableTextPara::GetEditViewForwarder( bool bCreate ) const @@ -2644,10 +2641,9 @@ namespace accessibility if (bValidPara) { // we explicitly allow for the index to point at the character right behind the text - if (0 <= nIndex && nIndex <= rCacheTF.GetTextLen( nPara )) - nRes = rCacheTF.GetLineNumberAtIndex( nPara, nIndex ); - else + if (0 > nIndex || nIndex > rCacheTF.GetTextLen( nPara )) throw lang::IndexOutOfBoundsException(); + nRes = rCacheTF.GetLineNumberAtIndex( nPara, nIndex ); } return nRes; } @@ -2663,27 +2659,24 @@ namespace accessibility DBG_ASSERT( bValidPara, "getTextAtLineNumber: current paragraph index out of range" ); if (bValidPara) { - if (0 <= nLineNo && nLineNo < rCacheTF.GetLineCount( nPara )) + if (0 > nLineNo || nLineNo >= rCacheTF.GetLineCount( nPara )) + throw lang::IndexOutOfBoundsException(); + sal_Int32 nStart = 0, nEnd = 0; + rCacheTF.GetLineBoundaries( nStart, nEnd, nPara, nLineNo ); + if (nStart >= 0 && nEnd >= 0) { - sal_Int32 nStart = 0, nEnd = 0; - rCacheTF.GetLineBoundaries( nStart, nEnd, nPara, nLineNo ); - if (nStart >= 0 && nEnd >= 0) + try { - try - { - aResult.SegmentText = getTextRange( nStart, nEnd ); - aResult.SegmentStart = nStart; - aResult.SegmentEnd = nEnd; - } - catch (const lang::IndexOutOfBoundsException&) - { - // this is not the exception that should be raised in this function ... - DBG_UNHANDLED_EXCEPTION(); - } + aResult.SegmentText = getTextRange( nStart, nEnd ); + aResult.SegmentStart = nStart; + aResult.SegmentEnd = nEnd; + } + catch (const lang::IndexOutOfBoundsException&) + { + // this is not the exception that should be raised in this function ... + DBG_UNHANDLED_EXCEPTION(); } } - else - throw lang::IndexOutOfBoundsException(); } return aResult; } diff --git a/editeng/source/accessibility/AccessibleImageBullet.cxx b/editeng/source/accessibility/AccessibleImageBullet.cxx index fe88afb6f37d..58cc35859957 100644 --- a/editeng/source/accessibility/AccessibleImageBullet.cxx +++ b/editeng/source/accessibility/AccessibleImageBullet.cxx @@ -484,13 +484,12 @@ namespace accessibility SvxEditSource& AccessibleImageBullet::GetEditSource() const { - if( mpEditSource ) - return *mpEditSource; - else + if( !mpEditSource ) throw uno::RuntimeException("No edit source, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + return *mpEditSource; } SvxTextForwarder& AccessibleImageBullet::GetTextForwarder() const @@ -505,13 +504,12 @@ namespace accessibility ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy - if( pTextForwarder->IsValid() ) - return *pTextForwarder; - else + if( !pTextForwarder->IsValid() ) throw uno::RuntimeException("Text forwarder is invalid, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + return *pTextForwarder; } SvxViewForwarder& AccessibleImageBullet::GetViewForwarder() const @@ -528,13 +526,12 @@ namespace accessibility ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy } - if( pViewForwarder->IsValid() ) - return *pViewForwarder; - else + if( !pViewForwarder->IsValid() ) throw uno::RuntimeException("View forwarder is invalid, object is defunct", uno::Reference< uno::XInterface > ( static_cast< ::cppu::OWeakObject* > ( const_cast< AccessibleImageBullet* > (this) ) ) ); // disambiguate hierarchy + return *pViewForwarder; } |