summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 11:06:43 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-21 15:29:20 +0200
commit3a481dde031ba416ec4ef0351130e26e49417418 (patch)
treeabfec5320c66e8c28b3da01852c531ef4a7ce0eb /editeng
parentac80f048f2bb23651ddc3c6608e9ef24635698d7 (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')
-rw-r--r--editeng/source/accessibility/AccessibleEditableTextPara.cxx51
-rw-r--r--editeng/source/accessibility/AccessibleImageBullet.cxx15
-rw-r--r--editeng/source/uno/unotext.cxx85
3 files changed, 69 insertions, 82 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;
}
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 6b209a6f2121..ebc6ee10fba9 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -2009,63 +2009,60 @@ void SvxPropertyValuesToItemSet(
for (sal_Int32 i = 0; i < nProps; ++i)
{
const SfxItemPropertySimpleEntry *pEntry = pPropSet->getPropertyMap().getByName( pProps[i].Name );
- if (pEntry)
- {
- // Note: there is no need to take special care of the properties
- // TextField (EE_FEATURE_FIELD) and
- // TextPortionType (WID_PORTIONTYPE)
- // since they are read-only and thus are already taken care of below.
+ if (!pEntry)
+ throw beans::UnknownPropertyException( "Unknown property: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
+ // Note: there is no need to take special care of the properties
+ // TextField (EE_FEATURE_FIELD) and
+ // TextPortionType (WID_PORTIONTYPE)
+ // since they are read-only and thus are already taken care of below.
- if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
- // should be PropertyVetoException which is not yet defined for the new import API's functions
- throw uno::RuntimeException("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
- //throw PropertyVetoException ("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
+ if (pEntry->nFlags & beans::PropertyAttribute::READONLY)
+ // should be PropertyVetoException which is not yet defined for the new import API's functions
+ throw uno::RuntimeException("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
+ //throw PropertyVetoException ("Property is read-only: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( 0 ) );
- if (pEntry->nWID == WID_FONTDESC)
- {
- awt::FontDescriptor aDesc;
- if (pProps[i].Value >>= aDesc)
- SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
- }
- else if (pEntry->nWID == WID_NUMLEVEL)
+ if (pEntry->nWID == WID_FONTDESC)
+ {
+ awt::FontDescriptor aDesc;
+ if (pProps[i].Value >>= aDesc)
+ SvxUnoFontDescriptor::FillItemSet( aDesc, rItemSet );
+ }
+ else if (pEntry->nWID == WID_NUMLEVEL)
+ {
+ if (pForwarder)
{
- if (pForwarder)
- {
- sal_Int16 nLevel = -1;
- pProps[i].Value >>= nLevel;
+ sal_Int16 nLevel = -1;
+ pProps[i].Value >>= nLevel;
- // #101004# Call interface method instead of unsafe cast
- if (!pForwarder->SetDepth( nPara, nLevel ))
- throw lang::IllegalArgumentException();
- }
+ // #101004# Call interface method instead of unsafe cast
+ if (!pForwarder->SetDepth( nPara, nLevel ))
+ throw lang::IllegalArgumentException();
}
- else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE )
+ }
+ else if (pEntry->nWID == WID_NUMBERINGSTARTVALUE )
+ {
+ if( pForwarder )
{
- if( pForwarder )
- {
- sal_Int16 nStartValue = -1;
- if( !(pProps[i].Value >>= nStartValue) )
- throw lang::IllegalArgumentException();
+ sal_Int16 nStartValue = -1;
+ if( !(pProps[i].Value >>= nStartValue) )
+ throw lang::IllegalArgumentException();
- pForwarder->SetNumberingStartValue( nPara, nStartValue );
- }
+ pForwarder->SetNumberingStartValue( nPara, nStartValue );
}
- else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART )
+ }
+ else if (pEntry->nWID == WID_PARAISNUMBERINGRESTART )
+ {
+ if( pForwarder )
{
- if( pForwarder )
- {
- bool bParaIsNumberingRestart = false;
- if( !(pProps[i].Value >>= bParaIsNumberingRestart) )
- throw lang::IllegalArgumentException();
+ bool bParaIsNumberingRestart = false;
+ if( !(pProps[i].Value >>= bParaIsNumberingRestart) )
+ throw lang::IllegalArgumentException();
- pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
- }
+ pForwarder->SetParaIsNumberingRestart( nPara, bParaIsNumberingRestart );
}
- else
- pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
}
else
- throw beans::UnknownPropertyException( "Unknown property: " + pProps[i].Name, static_cast < cppu::OWeakObject * > ( nullptr ) );
+ pPropSet->setPropertyValue( pProps[i].Name, pProps[i].Value, rItemSet );
}
}