From 5abf0c5ba9e036c7979b21a3be07df6a69a41e55 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Wed, 23 Dec 2015 19:48:42 +0100 Subject: refactor SwXStyle::get/setName Change-Id: If814b6873796fcfa4cc7a2f62711a8b20f2f7d6b --- sw/source/core/unocore/unostyle.cxx | 50 ++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 28 deletions(-) (limited to 'sw/source') diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index f1bcd9b3e7a0..16313afe6dd3 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1183,41 +1183,35 @@ void SwXStyle::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) OUString SwXStyle::getName() throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - if(m_pBasePool) - { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "where is the style?" ); - if(!pBase) - throw uno::RuntimeException(); - OUString aString; - SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true); - return aString; - } - return m_sStyleName; + if(!m_pBasePool) + return m_sStyleName; + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); + if(!pBase) + throw uno::RuntimeException(); + OUString aString; + SwStyleNameMapper::FillProgName(pBase->GetName(), aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true); + return aString; } void SwXStyle::setName(const OUString& rName) throw( uno::RuntimeException, std::exception ) { SolarMutexGuard aGuard; - if(m_pBasePool) + if(!m_pBasePool) { - m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); - SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); - OSL_ENSURE(pBase, "where is the style?" ); - bool bExcept = true; - if(pBase && pBase->IsUserDefined()) - { - rtl::Reference< SwDocStyleSheet > xTmp( new SwDocStyleSheet( *static_cast(pBase) ) ); - bExcept = !xTmp->SetName(rName); - if(!bExcept) - m_sStyleName = rName; - } - if(bExcept) - throw uno::RuntimeException(); - } - else m_sStyleName = rName; + return; + } + m_pBasePool->SetSearchMask(m_rEntry.m_eFamily); + SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName); + SAL_WARN_IF(!pBase, "sw.uno", "where is the style?"); + if(!pBase || !pBase->IsUserDefined()) + throw uno::RuntimeException(); + rtl::Reference xTmp(new SwDocStyleSheet(*static_cast(pBase))); + if(!xTmp->SetName(rName)) + throw uno::RuntimeException(); + m_sStyleName = rName; } sal_Bool SwXStyle::isUserDefined() throw( uno::RuntimeException, std::exception ) -- cgit v1.2.3