summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-09-22 15:32:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-09-23 09:04:48 +0200
commitee6bdeec8d618f039e72d496dff44beb5b99abb2 (patch)
treeeabd23b280c8a819137b3a2b22507ed8f1bfb858 /svx
parenta8622c77d26ca7a635afc95bba9a5054dc31eb7c (diff)
loplugin:flatten in svl..svx
and implement a check in the plugin to prevent us modifying the same patch of source code twice. This logic should probably be moved into plugin.cxx at some point. Change-Id: I7ebff6424cc8733bb2c8f7dba75eaaec68649290 Reviewed-on: https://gerrit.libreoffice.org/42660 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svx')
-rw-r--r--svx/source/accessibility/AccessibleTextHelper.cxx23
-rw-r--r--svx/source/accessibility/GraphCtlAccessibleContext.cxx42
-rw-r--r--svx/source/accessibility/charmapacc.cxx12
-rw-r--r--svx/source/table/tabledesign.cxx10
-rw-r--r--svx/source/unodraw/UnoNameItemTable.cxx6
-rw-r--r--svx/source/unodraw/unomtabl.cxx6
-rw-r--r--svx/source/unodraw/unoshap2.cxx7
-rw-r--r--svx/source/unogallery/unogalitem.cxx29
8 files changed, 61 insertions, 74 deletions
diff --git a/svx/source/accessibility/AccessibleTextHelper.cxx b/svx/source/accessibility/AccessibleTextHelper.cxx
index d38b26a68319..f14d5bbd4c01 100644
--- a/svx/source/accessibility/AccessibleTextHelper.cxx
+++ b/svx/source/accessibility/AccessibleTextHelper.cxx
@@ -281,10 +281,10 @@ namespace accessibility
if( !pTextForwarder )
throw uno::RuntimeException("Unable to fetch text forwarder, model might be dead", mxFrontEnd);
- if( pTextForwarder->IsValid() )
- return *pTextForwarder;
- else
+ if( !pTextForwarder->IsValid() )
throw uno::RuntimeException("Text forwarder is invalid, model might be dead", mxFrontEnd);
+
+ return *pTextForwarder;
}
SvxViewForwarder& AccessibleTextHelper_Impl::GetViewForwarder() const
@@ -297,10 +297,10 @@ namespace accessibility
if( !pViewForwarder )
throw uno::RuntimeException("Unable to fetch view forwarder, model might be dead", mxFrontEnd);
- if( pViewForwarder->IsValid() )
- return *pViewForwarder;
- else
+ if( !pViewForwarder->IsValid() )
throw uno::RuntimeException("View forwarder is invalid, model might be dead", mxFrontEnd);
+
+ return *pViewForwarder;
}
SvxEditViewForwarder& AccessibleTextHelper_Impl::GetEditViewForwarder() const
@@ -315,20 +315,19 @@ namespace accessibility
throw uno::RuntimeException("No edit view forwarder, object not in edit mode", mxFrontEnd);
}
- if( pViewForwarder->IsValid() )
- return *pViewForwarder;
- else
+ if( !pViewForwarder->IsValid() )
{
throw uno::RuntimeException("View forwarder is invalid, object not in edit mode", mxFrontEnd);
}
+
+ return *pViewForwarder;
}
SvxEditSourceAdapter& AccessibleTextHelper_Impl::GetEditSource() const
{
- if( maEditSource.IsValid() )
- return maEditSource;
- else
+ if( !maEditSource.IsValid() )
throw uno::RuntimeException("AccessibleTextHelper_Impl::GetEditSource: no edit source", mxFrontEnd );
+ return maEditSource;
}
// functor for sending child events (no stand-alone function, they are maybe not inlined)
diff --git a/svx/source/accessibility/GraphCtlAccessibleContext.cxx b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
index 3020c2cbf4de..274caf4badf3 100644
--- a/svx/source/accessibility/GraphCtlAccessibleContext.cxx
+++ b/svx/source/accessibility/GraphCtlAccessibleContext.cxx
@@ -175,26 +175,24 @@ Reference< XAccessible > SAL_CALL SvxGraphCtrlAccessibleContext::getAccessibleAt
Reference< XAccessible > xAccessible;
- if( mpControl )
+ if( !mpControl )
{
- Point aPnt( rPoint.X, rPoint.Y );
- mpControl->PixelToLogic( aPnt );
+ throw DisposedException();
+ }
- SdrObject* pObj = nullptr;
+ Point aPnt( rPoint.X, rPoint.Y );
+ mpControl->PixelToLogic( aPnt );
- if(mpView && mpView->GetSdrPageView())
- {
- pObj = SdrObjListPrimitiveHit(*mpPage, aPnt, 1, *mpView->GetSdrPageView(), nullptr, false);
- }
+ SdrObject* pObj = nullptr;
- if( pObj )
- xAccessible = getAccessible( pObj );
- }
- else
+ if(mpView && mpView->GetSdrPageView())
{
- throw DisposedException();
+ pObj = SdrObjListPrimitiveHit(*mpPage, aPnt, 1, *mpView->GetSdrPageView(), nullptr, false);
}
+ if( pObj )
+ xAccessible = getAccessible( pObj );
+
return xAccessible;
}
@@ -684,18 +682,16 @@ tools::Rectangle SvxGraphCtrlAccessibleContext::GetBoundingBox()
tools::Rectangle aBounds ( 0, 0, 0, 0 );
vcl::Window* pWindow = mpControl;
- if (pWindow != nullptr)
+ if (!(pWindow != nullptr))
+ throw DisposedException();
+
+ aBounds = pWindow->GetWindowExtentsRelative (nullptr);
+ vcl::Window* pParent = pWindow->GetAccessibleParentWindow();
+ if (pParent != nullptr)
{
- aBounds = pWindow->GetWindowExtentsRelative (nullptr);
- vcl::Window* pParent = pWindow->GetAccessibleParentWindow();
- if (pParent != nullptr)
- {
- tools::Rectangle aParentRect = pParent->GetWindowExtentsRelative (nullptr);
- aBounds -= aParentRect.TopLeft();
- }
+ tools::Rectangle aParentRect = pParent->GetWindowExtentsRelative (nullptr);
+ aBounds -= aParentRect.TopLeft();
}
- else
- throw DisposedException();
return aBounds;
}
diff --git a/svx/source/accessibility/charmapacc.cxx b/svx/source/accessibility/charmapacc.cxx
index 9e8c3ab5fa71..a0034b8beb40 100644
--- a/svx/source/accessibility/charmapacc.cxx
+++ b/svx/source/accessibility/charmapacc.cxx
@@ -333,15 +333,13 @@ uno::Reference< css::accessibility::XAccessible > SAL_CALL SvxShowCharSetAcc::ge
uno::Reference< css::accessibility::XAccessible > xRet;
SvxShowCharSetItem* pItem = m_pParent->getCharSetControl()->ImplGetItem( static_cast< sal_uInt16 >( i ) );
- if( pItem )
- {
- pItem->m_pParent = this;
- xRet = pItem->GetAccessible();
- m_aChildren.push_back(xRet);
- }
- else
+ if( !pItem )
throw lang::IndexOutOfBoundsException();
+ pItem->m_pParent = this;
+ xRet = pItem->GetAccessible();
+ m_aChildren.push_back(xRet);
+
return xRet;
}
diff --git a/svx/source/table/tabledesign.cxx b/svx/source/table/tabledesign.cxx
index 321c40d58b4d..8796bb7e649e 100644
--- a/svx/source/table/tabledesign.cxx
+++ b/svx/source/table/tabledesign.cxx
@@ -699,15 +699,13 @@ void TableDesignFamily::setPropertyValue( const OUString& , const Any& )
Any TableDesignFamily::getPropertyValue( const OUString& PropertyName )
{
- if ( PropertyName == "DisplayName" )
- {
- OUString sDisplayName( SvxResId( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
- return Any( sDisplayName );
- }
- else
+ if ( PropertyName != "DisplayName" )
{
throw UnknownPropertyException( "unknown property: " + PropertyName, static_cast<OWeakObject *>(this) );
}
+
+ OUString sDisplayName( SvxResId( RID_SVXSTR_STYLEFAMILY_TABLEDESIGN ) );
+ return Any( sDisplayName );
}
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
index 0a50dc3cfac2..33b72e5949f2 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -179,11 +179,11 @@ void SAL_CALL SvxUnoNameItemTable::replaceByName( const OUString& aApiName, cons
}
}
- if( bFound )
- ImplInsertByName( aName, aElement );
- else
+ if( !bFound )
throw container::NoSuchElementException();
+ ImplInsertByName( aName, aElement );
+
if( !hasByName( aName ) )
throw container::NoSuchElementException();
}
diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx
index 1bb12319bdd3..f64aa6449b13 100644
--- a/svx/source/unodraw/unomtabl.cxx
+++ b/svx/source/unodraw/unomtabl.cxx
@@ -263,10 +263,10 @@ void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const
}
}
- if( bFound )
- ImplInsertByName( aName, aElement );
- else
+ if( !bFound )
throw container::NoSuchElementException();
+
+ ImplInsertByName( aName, aElement );
}
static bool getByNameFromPool( const OUString& rSearchName, SfxItemPool const * pPool, sal_uInt16 nWhich, uno::Any& rAny )
diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx
index 409265aad00c..5ed67a209371 100644
--- a/svx/source/unodraw/unoshap2.cxx
+++ b/svx/source/unodraw/unoshap2.cxx
@@ -308,13 +308,10 @@ sal_Int32 SAL_CALL SvxShapeGroup::getCount()
{
::SolarMutexGuard aGuard;
- sal_Int32 nRetval = 0;
-
- if(mpObj.is() && mpObj->GetSubList())
- nRetval = mpObj->GetSubList()->GetObjCount();
- else
+ if(!mpObj.is() || !mpObj->GetSubList())
throw uno::RuntimeException();
+ sal_Int32 nRetval = mpObj->GetSubList()->GetObjCount();
return nRetval;
}
diff --git a/svx/source/unogallery/unogalitem.cxx b/svx/source/unogallery/unogalitem.cxx
index 38d752220b87..ea8543a839a8 100644
--- a/svx/source/unogallery/unogalitem.cxx
+++ b/svx/source/unogallery/unogalitem.cxx
@@ -215,28 +215,27 @@ void GalleryItem::_setPropertyValues( const comphelper::PropertyMapEntry** ppEnt
{
OUString aNewTitle;
- if( *pValues >>= aNewTitle )
+ if( !(*pValues >>= aNewTitle) )
{
- ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : nullptr );
+ throw lang::IllegalArgumentException();
+ }
- if( pGalTheme )
- {
- std::unique_ptr<SgaObject> pObj(pGalTheme->ImplReadSgaObject( const_cast< GalleryObject* >( implGetObject() ) ));
+ ::GalleryTheme* pGalTheme = ( isValid() ? mpTheme->implGetTheme() : nullptr );
- if( pObj )
+ if( pGalTheme )
+ {
+ std::unique_ptr<SgaObject> pObj(pGalTheme->ImplReadSgaObject( const_cast< GalleryObject* >( implGetObject() ) ));
+
+ if( pObj )
+ {
+ if( pObj->GetTitle() != aNewTitle )
{
- if( pObj->GetTitle() != aNewTitle )
- {
- pObj->SetTitle( aNewTitle );
- pGalTheme->InsertObject( *pObj );
- }
+ pObj->SetTitle( aNewTitle );
+ pGalTheme->InsertObject( *pObj );
}
}
}
- else
- {
- throw lang::IllegalArgumentException();
- }
+
}
++ppEntries;