Kaydet (Commit) 394895de authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

use a map for dispatch

Change-Id: I29c88c834a01f8d04a2998ea3edfa95cd0cadb85
üst ec5e17c4
...@@ -1812,72 +1812,47 @@ void SwXStyle::SetPropertyValue<RES_PARATR_NUMRULE>(const SfxItemPropertySimpleE ...@@ -1812,72 +1812,47 @@ void SwXStyle::SetPropertyValue<RES_PARATR_NUMRULE>(const SfxItemPropertySimpleE
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) 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)
{ {
switch(rEntry.nWID) using propertytype_t = decltype(rEntry.nWID);
using coresetter_t = std::function<void(SwXStyle&, const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, const uno::Any&, SwStyleBase_Impl&)>;
static std::unique_ptr<std::map<propertytype_t, coresetter_t>> pUnoToCore;
if(!pUnoToCore)
{ {
case FN_UNO_HIDDEN: pUnoToCore.reset(new std::map<propertytype_t, coresetter_t> {
SetPropertyValue<FN_UNO_HIDDEN>(rEntry, rPropSet, rValue, rBase); // these explicit std::mem_fn() calls shouldnt be needed, but apparently MSVC is currently too stupid for C++11 again
break; { FN_UNO_HIDDEN, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_HIDDEN>) },
case FN_UNO_STYLE_INTEROP_GRAB_BAG: { FN_UNO_STYLE_INTEROP_GRAB_BAG, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_STYLE_INTEROP_GRAB_BAG>) },
SetPropertyValue<FN_UNO_STYLE_INTEROP_GRAB_BAG>(rEntry, rPropSet, rValue, rBase); { XATTR_FILLGRADIENT, std::mem_fn(&SwXStyle::SetPropertyValue<XATTR_FILLGRADIENT>) },
break; { XATTR_FILLHATCH, std::mem_fn(&SwXStyle::SetPropertyValue<XATTR_FILLGRADIENT>) },
case XATTR_FILLGRADIENT: { XATTR_FILLBITMAP, std::mem_fn(&SwXStyle::SetPropertyValue<XATTR_FILLGRADIENT>) },
case XATTR_FILLHATCH: { XATTR_FILLFLOATTRANSPARENCE, std::mem_fn(&SwXStyle::SetPropertyValue<XATTR_FILLGRADIENT>) },
case XATTR_FILLBITMAP: { RES_BACKGROUND, std::mem_fn(&SwXStyle::SetPropertyValue<RES_BACKGROUND>) },
case XATTR_FILLFLOATTRANSPARENCE: { OWN_ATTR_FILLBMP_MODE, std::mem_fn(&SwXStyle::SetPropertyValue<OWN_ATTR_FILLBMP_MODE>) },
SetPropertyValue<XATTR_FILLGRADIENT>(rEntry, rPropSet, rValue, rBase); { RES_PAPER_BIN, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PAPER_BIN>) },
break; { FN_UNO_NUM_RULES, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_NUM_RULES>) },
case RES_BACKGROUND: { RES_PARATR_OUTLINELEVEL, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PARATR_OUTLINELEVEL>) },
SetPropertyValue<RES_BACKGROUND>(rEntry, rPropSet, rValue, rBase); { FN_UNO_FOLLOW_STYLE, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>) },
break; { RES_PAGEDESC, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PAGEDESC>) },
case OWN_ATTR_FILLBMP_MODE: { RES_TEXT_VERT_ADJUST, std::mem_fn(&SwXStyle::SetPropertyValue<RES_TEXT_VERT_ADJUST>) },
SetPropertyValue<OWN_ATTR_FILLBMP_MODE>(rEntry, rPropSet, rValue, rBase); { FN_UNO_IS_AUTO_UPDATE, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_IS_AUTO_UPDATE>) },
break; { FN_UNO_PARA_STYLE_CONDITIONS, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>) },
case RES_PAPER_BIN: { FN_UNO_CATEGORY, std::mem_fn(&SwXStyle::SetPropertyValue<FN_UNO_CATEGORY>) },
SetPropertyValue<RES_PAPER_BIN>(rEntry, rPropSet, rValue, rBase); { SID_SWREGISTER_COLLECTION, std::mem_fn(&SwXStyle::SetPropertyValue<SID_SWREGISTER_COLLECTION>) },
break; { RES_TXTATR_CJK_RUBY, std::mem_fn(&SwXStyle::SetPropertyValue<RES_TXTATR_CJK_RUBY>) },
case FN_UNO_NUM_RULES: // special handling for a SvxNumRuleItem: { RES_PARATR_DROP, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PARATR_DROP>) },
SetPropertyValue<FN_UNO_NUM_RULES>(rEntry, rPropSet, rValue, rBase); { RES_PARATR_DROP, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PARATR_DROP>) },
break; { RES_PARATR_NUMRULE, std::mem_fn(&SwXStyle::SetPropertyValue<RES_PARATR_NUMRULE>) }
case RES_PARATR_OUTLINELEVEL: });
SetPropertyValue<RES_PARATR_OUTLINELEVEL>(rEntry, rPropSet, rValue, rBase); }
break; const auto pUnoToCoreIt(pUnoToCore->find(rEntry.nWID));
case FN_UNO_FOLLOW_STYLE: if(pUnoToCoreIt != pUnoToCore->end())
SetPropertyValue<FN_UNO_FOLLOW_STYLE>(rEntry, rPropSet, rValue, rBase); pUnoToCoreIt->second(*this, rEntry, rPropSet, rValue, rBase);
break; else
case RES_PAGEDESC: {
SetPropertyValue<RES_PAGEDESC>(rEntry, rPropSet, rValue, rBase); //UUUU adapted switch logic to a more readable state; removed goto's and made
break; // execution of standard setting of proerty in ItemSet dependent of this variable
case RES_TEXT_VERT_ADJUST: uno::Any aValue(rValue);
SetPropertyValue<RES_TEXT_VERT_ADJUST>(rEntry, rPropSet, rValue, rBase); lcl_TranslateMetric(rEntry, m_pDoc, aValue);
break; lcl_SetDefaultWay(rEntry, rPropSet, aValue, rBase);
case FN_UNO_IS_AUTO_UPDATE:
SetPropertyValue<FN_UNO_IS_AUTO_UPDATE>(rEntry, rPropSet, rValue, rBase);
break;
case FN_UNO_PARA_STYLE_CONDITIONS:
SetPropertyValue<FN_UNO_PARA_STYLE_CONDITIONS>(rEntry, rPropSet, rValue, rBase);
break;
case FN_UNO_CATEGORY:
SetPropertyValue<FN_UNO_CATEGORY>(rEntry, rPropSet, rValue, rBase);
break;
case SID_SWREGISTER_COLLECTION:
SetPropertyValue<SID_SWREGISTER_COLLECTION>(rEntry, rPropSet, rValue, rBase);
break;
case RES_TXTATR_CJK_RUBY:
SetPropertyValue<RES_TXTATR_CJK_RUBY>(rEntry, rPropSet, rValue, rBase);
break;
case RES_PARATR_DROP:
SetPropertyValue<RES_PARATR_DROP>(rEntry, rPropSet, rValue, rBase);
break;
case RES_PARATR_NUMRULE:
SetPropertyValue<RES_PARATR_NUMRULE>(rEntry, rPropSet, rValue, rBase);
break;
default:
//UUUU adapted switch logic to a more readable state; removed goto's and made
// execution of standard setting of proerty in ItemSet dependent of this variable
uno::Any aValue(rValue);
lcl_TranslateMetric(rEntry, m_pDoc, aValue);
lcl_SetDefaultWay(rEntry, rPropSet, aValue, rBase);
break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment