diff options
author | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-03-12 00:13:56 +0100 |
---|---|---|
committer | Bjoern Michaelsen <bjoern.michaelsen@canonical.com> | 2016-03-17 23:54:43 +0100 |
commit | bf9b147b1b1e87b59185e9a94a5dbb1945379972 (patch) | |
tree | 0b9fd57778badd123660777df1191bea3c2e83d5 | |
parent | 150c1dcab007dd8acc1551791f42eef692f9e531 (diff) |
refactor out to limit scope: RES_PAGEDESC
also check preconditions early
Change-Id: I11c6616ce2ca1b6634760b68387faf4139af7ca7
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index ce6573820e96..7647be9edc89 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2026,7 +2026,6 @@ uno::Any SwXStyle::GetStyleProperty<RES_PARATR_OUTLINELEVEL>(const SfxItemProper SAL_WARN_IF(SFX_STYLE_FAMILY_PARA == GetFamily(), "sw.uno", "only paras"); return uno::makeAny<sal_Int16>(rBase.getNewBase()->GetCollection()->GetAttrOutlineLevel()); } - template<> uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(const SfxItemPropertySimpleEntry&, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) throw(uno::RuntimeException, std::exception) @@ -2035,6 +2034,25 @@ uno::Any SwXStyle::GetStyleProperty<FN_UNO_FOLLOW_STYLE>(const SfxItemPropertySi SwStyleNameMapper::FillProgName(rBase.getNewBase()->GetFollow(), aString, lcl_GetSwEnumFromSfxEnum(GetFamily()), true); return uno::makeAny(aString); } +template<> +uno::Any SwXStyle::GetStyleProperty<RES_PAGEDESC>(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet&, SwStyleBase_Impl& rBase) + throw(uno::RuntimeException, std::exception) +{ + const sal_uInt8 nMemberId(rEntry.nMemberId & (~SFX_METRIC_ITEM)); + if(MID_PAGEDESC_PAGEDESCNAME != nMemberId) + return uno::Any(); + // special handling for RES_PAGEDESC + const SfxPoolItem* pItem; + if(SfxItemState::SET != rBase.GetItemSet().GetItemState(RES_PAGEDESC, true, &pItem)) + return uno::Any(); + const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc(); + if(!pDesc) + return uno::Any(); + OUString aString; + SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true); + return uno::makeAny(aString); +} + uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, SwStyleBase_Impl& rBase) throw(uno::RuntimeException, std::exception) { @@ -2085,27 +2103,14 @@ uno::Any SwXStyle::lcl_GetStyleProperty(const SfxItemPropertySimpleEntry& rEntry { return GetStyleProperty<FN_UNO_FOLLOW_STYLE>(rEntry, rPropSet, rBase); } - case RES_PAGEDESC : + case RES_PAGEDESC: { if (MID_PAGEDESC_PAGEDESCNAME != nMemberId) { bHandleDefaulyWay = true; break; } - // special handling for RES_PAGEDESC - const SfxPoolItem* pItem; - if (SfxItemState::SET == rBase.GetItemSet().GetItemState(RES_PAGEDESC, true, &pItem)) - { - const SwPageDesc* pDesc = static_cast<const SwFormatPageDesc*>(pItem)->GetPageDesc(); - if(pDesc) - { - OUString aString; - SwStyleNameMapper::FillProgName(pDesc->GetName(), aString, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true ); - aRet <<= aString; - } - - } - break; + return GetStyleProperty<RES_PAGEDESC>(rEntry, rPropSet, rBase); } case FN_UNO_IS_AUTO_UPDATE: { |