From 209030f9fb87067fac57436e8e359380e0c4b584 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Thu, 14 Jan 2016 20:52:53 +0100 Subject: refactor out to limit scope: RES_TXTATR_CJK_RUBY Change-Id: I02b37ead4f930a91f9e8c6d472ffe0d2991bb78f --- sw/source/core/unocore/unostyle.cxx | 56 ++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'sw') diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index ece91c4f76e9..db1380967b94 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -1741,7 +1741,32 @@ void SwXStyle::SetPropertyValue(const SfxItemProperty SwStyleNameMapper::FillUIName(sName, aString, nsSwGetPoolIdFromName::GET_POOLID_TXTCOLL, true); o_rStyleBase.GetItemSet().Put(SfxStringItem(SID_SWREGISTER_COLLECTION, aString ) ); } - +template<> +void SwXStyle::SetPropertyValue(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet&, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase) +{ + if(MID_RUBY_CHARSTYLE != rEntry.nMemberId) + return; + if(!rValue.has()) + throw lang::IllegalArgumentException(); + const auto sValue(rValue.get()); + SfxItemSet& rStyleSet(o_rStyleBase.GetItemSet()); + std::unique_ptr pRuby; + const SfxPoolItem* pItem; + if(SfxItemState::SET == rStyleSet.GetItemState(RES_TXTATR_CJK_RUBY, true, &pItem)) + pRuby.reset(new SwFormatRuby(*static_cast(pItem))); + else + pRuby.reset(new SwFormatRuby(OUString())); + OUString sStyle; + SwStyleNameMapper::FillUIName(sValue, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true); + pRuby->SetCharFormatName(sValue); + pRuby->SetCharFormatId(0); + if(!sValue.isEmpty()) + { + const sal_uInt16 nId(SwStyleNameMapper::GetPoolIdFromUIName(sValue, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT)); + pRuby->SetCharFormatId(nId); + } + rStyleSet.Put(*pRuby); +} 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) { @@ -1825,35 +1850,8 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const break; } case RES_TXTATR_CJK_RUBY: - { - if(MID_RUBY_CHARSTYLE == nMemberId ) - { - OUString sTmp; - if(aValue >>= sTmp) - { - SfxItemSet& rStyleSet = rBase.GetItemSet(); - std::unique_ptr pRuby; - const SfxPoolItem* pItem; - if(SfxItemState::SET == rStyleSet.GetItemState( RES_TXTATR_CJK_RUBY, true, &pItem ) ) - pRuby.reset(new SwFormatRuby(*static_cast(pItem))); - else - pRuby.reset(new SwFormatRuby(OUString())); - OUString sStyle; - SwStyleNameMapper::FillUIName(sTmp, sStyle, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT, true ); - pRuby->SetCharFormatName( sTmp ); - pRuby->SetCharFormatId( 0 ); - if(!sTmp.isEmpty()) - { - sal_uInt16 nId = SwStyleNameMapper::GetPoolIdFromUIName( sTmp, nsSwGetPoolIdFromName::GET_POOLID_CHRFMT ); - pRuby->SetCharFormatId(nId); - } - rStyleSet.Put(*pRuby); - } - else - throw lang::IllegalArgumentException(); - } + SetPropertyValue(rEntry, rPropSet, rValue, rBase); break; - } case RES_PARATR_DROP: { if( MID_DROPCAP_CHAR_STYLE_NAME == nMemberId) -- cgit