From 0729e946388c4cbf3dce2971ccad30290ce66497 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Sat, 28 Nov 2015 02:54:53 +0100 Subject: clean up and reduce indent levels Change-Id: If35b67439eee347d15a55e965756466db1cb466c --- sw/source/core/unocore/unostyle.cxx | 91 ++++++++++++++----------------------- 1 file changed, 35 insertions(+), 56 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 2f0b67036a09..2b321f4324e8 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -644,66 +644,45 @@ void SwXStyleFamily::insertByName(const OUString& rName, const uno::Any& rElemen throw( lang::IllegalArgumentException, container::ElementExistException, lang::WrappedTargetException, uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - if(m_pBasePool) + if(!m_pBasePool) + throw uno::RuntimeException(); + OUString sStyleName; + SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum(m_eFamily), true); + m_pBasePool->SetSearchMask(m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName); + SfxStyleSheetBase* pUINameBase = m_pBasePool->Find( sStyleName ); + if(pBase || pUINameBase) + throw container::ElementExistException(); + if(rElement.getValueType().getTypeClass() != uno::TypeClass_INTERFACE) + throw lang::IllegalArgumentException(); + uno::Reference xStyleTunnel = rElement.get>(); + SwXStyle* pNewStyle = nullptr; + if(xStyleTunnel.is()) { - OUString sStyleName; - SwStyleNameMapper::FillUIName(rName, sStyleName, lcl_GetSwEnumFromSfxEnum ( m_eFamily ), true); - m_pBasePool->SetSearchMask(m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(sStyleName); - SfxStyleSheetBase* pUINameBase = m_pBasePool->Find( sStyleName ); - if(pBase || pUINameBase) - throw container::ElementExistException(); - else - { - if(rElement.getValueType().getTypeClass() == - uno::TypeClass_INTERFACE) - { - uno::Reference< uno::XInterface > const * pxRef = - static_cast const *>(rElement.getValue()); - - uno::Reference xStyleTunnel( *pxRef, uno::UNO_QUERY); - - SwXStyle* pNewStyle = nullptr; - if(xStyleTunnel.is()) - { - pNewStyle = reinterpret_cast< SwXStyle * >( - sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) )); - } - - if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_eFamily) - throw lang::IllegalArgumentException(); + pNewStyle = reinterpret_cast< SwXStyle * >( + sal::static_int_cast< sal_IntPtr >( xStyleTunnel->getSomething( SwXStyle::getUnoTunnelId()) )); + } - sal_uInt16 nMask = SFXSTYLEBIT_ALL; - if(m_eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional()) - nMask &= ~SWSTYLEBIT_CONDCOLL; -#if OSL_DEBUG_LEVEL > 1 - SfxStyleSheetBase& rNewBase = -#endif - m_pBasePool->Make(sStyleName, m_eFamily, nMask); - pNewStyle->SetDoc(m_pDocShell->GetDoc(), m_pBasePool); - pNewStyle->SetStyleName(sStyleName); - const OUString sParentStyleName(pNewStyle->GetParentStyleName()); - if (!sParentStyleName.isEmpty()) - { - m_pBasePool->SetSearchMask(m_eFamily); - SfxStyleSheetBase* pParentBase = m_pBasePool->Find(sParentStyleName); - if(pParentBase && pParentBase->GetFamily() == m_eFamily && - &pParentBase->GetPool() == m_pBasePool) - m_pBasePool->SetParent( m_eFamily, sStyleName, sParentStyleName ); + if (!pNewStyle || !pNewStyle->IsDescriptor() || pNewStyle->GetFamily() != m_eFamily) + throw lang::IllegalArgumentException(); - } -#if OSL_DEBUG_LEVEL > 1 - (void)rNewBase; -#endif - // after all, we still need to apply the properties of the descriptor - pNewStyle->ApplyDescriptorProperties(); - } - else - throw lang::IllegalArgumentException(); - } + sal_uInt16 nMask = SFXSTYLEBIT_ALL; + if(m_eFamily == SFX_STYLE_FAMILY_PARA && !pNewStyle->IsConditional()) + nMask &= ~SWSTYLEBIT_CONDCOLL; + m_pBasePool->Make(sStyleName, m_eFamily, nMask); + pNewStyle->SetDoc(m_pDocShell->GetDoc(), m_pBasePool); + pNewStyle->SetStyleName(sStyleName); + const OUString sParentStyleName(pNewStyle->GetParentStyleName()); + if (!sParentStyleName.isEmpty()) + { + m_pBasePool->SetSearchMask(m_eFamily); + SfxStyleSheetBase* pParentBase = m_pBasePool->Find(sParentStyleName); + if(pParentBase && pParentBase->GetFamily() == m_eFamily && + &pParentBase->GetPool() == m_pBasePool) + m_pBasePool->SetParent(m_eFamily, sStyleName, sParentStyleName); } - else - throw uno::RuntimeException(); + // after all, we still need to apply the properties of the descriptor + pNewStyle->ApplyDescriptorProperties(); } void SwXStyleFamily::replaceByName(const OUString& rName, const uno::Any& rElement) -- cgit v1.2.3