summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-01-14 21:05:59 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-01-15 21:42:47 +0100
commitd409cb6e96d26c34b299f651989794f15a64a75d (patch)
tree73d1e45ef6c9d8b6680a59c6978a9b428c64d68d
parentb4f04b0d584836c6570c5bdecd421c6e62464963 (diff)
refactor out to limit scope: RES_PARATR_DROP
Change-Id: I8813b5676504e6de2af70d181fa9e905538fb05c
-rw-r--r--sw/source/core/unocore/unostyle.cxx56
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);