diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-12-23 19:48:42 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2015-12-24 00:03:45 +0100 |
commit | 5abf0c5ba9e036c7979b21a3be07df6a69a41e55 (patch) | |
tree | bda6c7fa09629ece8d2e5b392efec91315ffde7d | |
parent | f342a0043e285cd1cab9bc943b372fb6ec0d90c2 (diff) |
refactor SwXStyle::get/setName
Change-Id: If814b6873796fcfa4cc7a2f62711a8b20f2f7d6b
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 50 |
1 files changed, 22 insertions, 28 deletions
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<SwDocStyleSheet*>(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<SwDocStyleSheet> xTmp(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase))); + if(!xTmp->SetName(rName)) + throw uno::RuntimeException(); + m_sStyleName = rName; } sal_Bool SwXStyle::isUserDefined() throw( uno::RuntimeException, std::exception ) |