diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-26 11:32:13 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-09-26 14:16:13 +0200 |
commit | 0b4135ec9945ea627318ecf5fccc4b7d0940ff0d (patch) | |
tree | 656dfb32b2e8908e29fe41c9b83ec0cb09038c17 /sw/source/uibase/uno/unoatxt.cxx | |
parent | 96e3c301d87906a4728f06b4ce5a930d2090e1c2 (diff) |
loplugin:flatten in sw
Change-Id: I77d92e7adc9af5c88ca1930c25a0585713f9e0d3
Reviewed-on: https://gerrit.libreoffice.org/42788
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/uibase/uno/unoatxt.cxx')
-rw-r--r-- | sw/source/uibase/uno/unoatxt.cxx | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/sw/source/uibase/uno/unoatxt.cxx b/sw/source/uibase/uno/unoatxt.cxx index 5d57bb4cdc22..9091fb7208a6 100644 --- a/sw/source/uibase/uno/unoatxt.cxx +++ b/sw/source/uibase/uno/unoatxt.cxx @@ -270,27 +270,26 @@ void SwXAutoTextGroup::renameByName(const OUString& aElementName, if(aNewElementName != aElementName && hasByName(aNewElementName)) throw container::ElementExistException(); std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr); - if(pGlosGroup && !pGlosGroup->GetError()) + if(!pGlosGroup || pGlosGroup->GetError()) + throw uno::RuntimeException(); + + sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName); + if(USHRT_MAX == nIdx) + throw lang::IllegalArgumentException(); + OUString aNewShort(aNewElementName); + OUString aNewName(aNewElementTitle); + sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort ); + sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName ); + + if( nIdx != USHRT_MAX && + (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&& + (nOldIdx == USHRT_MAX || nOldIdx == nIdx )) { - sal_uInt16 nIdx = pGlosGroup->GetIndex( aElementName); - if(USHRT_MAX == nIdx) - throw lang::IllegalArgumentException(); - OUString aNewShort(aNewElementName); - OUString aNewName(aNewElementTitle); - sal_uInt16 nOldLongIdx = pGlosGroup->GetLongIndex( aNewShort ); - sal_uInt16 nOldIdx = pGlosGroup->GetIndex( aNewName ); - - if( nIdx != USHRT_MAX && - (nOldLongIdx == USHRT_MAX || nOldLongIdx == nIdx )&& - (nOldIdx == USHRT_MAX || nOldIdx == nIdx )) - { - pGlosGroup->Rename( nIdx, &aNewShort, &aNewName ); - if(pGlosGroup->GetError() != ERRCODE_NONE) - throw io::IOException(); - } + pGlosGroup->Rename( nIdx, &aNewShort, &aNewName ); + if(pGlosGroup->GetError() != ERRCODE_NONE) + throw io::IOException(); } - else - throw uno::RuntimeException(); + } static bool lcl_CopySelToDoc( SwDoc* pInsDoc, OTextCursorHelper* pxCursor, SwXTextRange* pxRange) @@ -433,14 +432,12 @@ void SwXAutoTextGroup::removeByName(const OUString& aEntryName) { SolarMutexGuard aGuard; std::unique_ptr<SwTextBlocks> pGlosGroup(pGlossaries ? pGlossaries->GetGroupDoc(m_sGroupName) : nullptr); - if(pGlosGroup && !pGlosGroup->GetError()) - { - sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName); - if ( nIdx != USHRT_MAX ) - pGlosGroup->Delete(nIdx); - } - else + if(!pGlosGroup || pGlosGroup->GetError()) throw container::NoSuchElementException(); + + sal_uInt16 nIdx = pGlosGroup->GetIndex(aEntryName); + if ( nIdx != USHRT_MAX ) + pGlosGroup->Delete(nIdx); } OUString SwXAutoTextGroup::getName() |