summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-12-23 20:29:24 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2015-12-24 00:03:47 +0100
commit52d568f29994fbfcda675e4a519d3c50543c9703 (patch)
treef334a1c79d5ef908a4b6ec34b94ca76858099c37
parentcf25dad00c68e0c753b060737ba0eeab971f970f (diff)
refactor SwXStyle::get/setParentStyle
Change-Id: Ifb578244d511af153484d14ee92c5c22c2db0a3f
-rw-r--r--sw/source/core/unocore/unostyle.cxx74
1 files changed, 29 insertions, 45 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index 9b8d860dc4bc..c66a434a95d9 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1238,68 +1238,52 @@ sal_Bool SwXStyle::isInUse() throw( uno::RuntimeException, std::exception )
OUString SwXStyle::getParentStyle() throw( uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
- OUString aString;
- if(m_pBasePool)
+ if(!m_pBasePool)
{
- m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
- SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName);
- if(pBase)
- aString = pBase->GetParent();
+ if(!m_bIsDescriptor)
+ throw uno::RuntimeException();
+ return m_sParentStyleName;
}
- else if(m_bIsDescriptor)
- aString = m_sParentStyleName;
- else
- throw uno::RuntimeException();
- SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true );
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
+ SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName);
+ OUString aString;
+ if(pBase)
+ aString = pBase->GetParent();
+ SwStyleNameMapper::FillProgName(aString, aString, lcl_GetSwEnumFromSfxEnum(m_rEntry.m_eFamily), true);
return aString;
}
-void SwXStyle::setParentStyle(const OUString& rParentStyle)
- throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
+void SwXStyle::setParentStyle(const OUString& rParentStyle) throw( container::NoSuchElementException, uno::RuntimeException, std::exception )
{
SolarMutexGuard aGuard;
OUString sParentStyle;
SwStyleNameMapper::FillUIName(rParentStyle, sParentStyle, lcl_GetSwEnumFromSfxEnum ( m_rEntry.m_eFamily ), true );
- if(m_pBasePool)
+ if(!m_pBasePool)
{
- m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
- bool bExcept = false;
- SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName);
- if(pBase)
- {
- rtl::Reference< SwDocStyleSheet > xBase( new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)) );
- //make it a 'real' style - necessary for pooled styles
- xBase->GetItemSet();
- if(xBase->GetParent() != sParentStyle)
- {
- bExcept = !xBase->SetParent(sParentStyle);
- }
- }
- else
- bExcept = true;
- if(bExcept)
+ if(!m_bIsDescriptor)
throw uno::RuntimeException();
- }
- else if(m_bIsDescriptor)
- {
m_sParentStyleName = sParentStyle;
try
{
- uno::Any aAny = m_xStyleFamily->getByName ( sParentStyle );
- aAny >>= m_xStyleData;
- }
- catch ( container::NoSuchElementException& )
- {
- }
- catch ( lang::WrappedTargetException& )
- {
- }
- catch ( uno::RuntimeException& )
- {
+ const auto aAny = m_xStyleFamily->getByName(sParentStyle);
+ m_xStyleData = aAny.get<decltype(m_xStyleData)>();
}
+ catch(...)
+ { }
+ return;
}
- else
+ m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
+ SfxStyleSheetBase* pBase = m_pBasePool->Find(m_sStyleName);
+ if(!pBase)
throw uno::RuntimeException();
+ rtl::Reference<SwDocStyleSheet> xBase(new SwDocStyleSheet(*static_cast<SwDocStyleSheet*>(pBase)));
+ //make it a 'real' style - necessary for pooled styles
+ xBase->GetItemSet();
+ if(xBase->GetParent() != sParentStyle)
+ {
+ if(!xBase->SetParent(sParentStyle))
+ throw uno::RuntimeException();
+ }
}
static uno::Reference< beans::XPropertySetInfo > lcl_getPropertySetInfo( SfxStyleFamily eFamily, bool bIsConditional )