diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-01-14 21:05:59 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-01-16 11:03:06 +0100 |
commit | 6766760e86b517c726204f9601b33a19cb0c5451 (patch) | |
tree | e6bd097bcb7f49d5bae0265960ddb3f73f18f065 /sw/source | |
parent | 209030f9fb87067fac57436e8e359380e0c4b584 (diff) |
refactor out to limit scope: RES_PARATR_DROP
Change-Id: I8813b5676504e6de2af70d181fa9e905538fb05c
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index db1380967b94..328b55f0f611 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1767,6 +1767,29 @@ void SwXStyle::SetPropertyValue<RES_TXTATR_CJK_RUBY>(const SfxItemPropertySimple } rStyleSet.Put(*pRuby); } +template<> +void SwXStyle::SetPropertyValue<RES_PARATR_DROP>(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet&, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase) +{ + if(MID_DROPCAP_CHAR_STYLE_NAME != rEntry.nMemberId) + return; + if(!rValue.has<OUString>()) + throw lang::IllegalArgumentException(); + SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet()); + std::unique_ptr<SwFormatDrop> pDrop; + const SfxPoolItem* pItem; + if(SfxItemState::SET == rStyleSet.GetItemState(RES_PARATR_DROP, true, &pItem)) + pDrop.reset(new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem))); + else + pDrop.reset(new SwFormatDrop); + const auto sValue(rValue.get<OUString>()); + OUString sStyle; + SwStyleNameMapper::FillUIName(sValue, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true); + auto pStyle(static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR))); + if(!pStyle) + throw lang::IllegalArgumentException(); + pDrop->SetCharFormat(pStyle->GetCharFormat()); + rStyleSet.Put(*pDrop); +} void SwXStyle::SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, const uno::Any& rValue, SwStyleBase_Impl& rBase) throw(beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception) { @@ -1853,38 +1876,9 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SetPropertyValue<RES_TXTATR_CJK_RUBY>(rEntry, rPropSet, rValue, rBase); break; case RES_PARATR_DROP: - { - if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId) - { - if(aValue.getValueType() == ::cppu::UnoType<OUString>::get()) - { - SfxItemSet& rStyleSet = rBase.GetItemSet(); - - std::unique_ptr<SwFormatDrop> pDrop; - const SfxPoolItem* pItem; - if(SfxItemState::SET == rStyleSet.GetItemState( RES_PARATR_DROP, true, &pItem ) ) - pDrop.reset(new SwFormatDrop(*static_cast<const SwFormatDrop*>(pItem))); - else - pDrop.reset( new SwFormatDrop ); - OUString uStyle; - aValue >>= uStyle; - OUString sStyle; - SwStyleNameMapper::FillUIName(uStyle, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true ); - SwDocStyleSheet* pStyle = - static_cast<SwDocStyleSheet*>(pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SFX_STYLE_FAMILY_CHAR)); - if(pStyle) - pDrop->SetCharFormat(pStyle->GetCharFormat()); - else - throw lang::IllegalArgumentException(); - rStyleSet.Put(*pDrop); - } - else - throw lang::IllegalArgumentException(); - - bDone = true; - } + SetPropertyValue<RES_PARATR_DROP>(rEntry, rPropSet, rValue, rBase); + bDone = true; break; - } case RES_PARATR_NUMRULE: { lcl_SetDefaultWay(rEntry, rPropSet, aValue, rBase); |