summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-01-02 18:32:54 +0100
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2016-01-15 21:42:44 +0100
commitafcb3d2a01c322cbc2cef0be47d3f23f93c3273c (patch)
treee6819d668a4e63edfd68a4c16a5e5f36306ad27e
parent264e845e8ccfb001b310c8f745e9aa5bbe6a1095 (diff)
refactor out to limit scope: RES_PAGEDESC
Change-Id: Id5c83f8dcc19dc5e94a895f1e15bc5dc8e800d9f
-rw-r--r--sw/source/core/unocore/unostyle.cxx87
1 files changed, 39 insertions, 48 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index f825542214cb..88e96fb5526d 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -1616,7 +1616,43 @@ void SwXStyle::SetPropertyValue<FN_UNO_FOLLOW_STYLE>(const SfxItemPropertySimple
SwStyleNameMapper::FillUIName(sValue, aString, m_rEntry.m_aPoolId, true);
o_rStyleBase.getNewBase()->SetFollow(aString);
}
-
+template<>
+void SwXStyle::SetPropertyValue<RES_PAGEDESC>(const SfxItemPropertySimpleEntry& rEntry, const SfxItemPropertySet& rPropSet, const uno::Any& rValue, SwStyleBase_Impl& o_rStyleBase)
+{
+ if(MID_PAGEDESC_PAGEDESCNAME != rEntry.nMemberId)
+ {
+ lcl_SetDefaultWay(rEntry, rPropSet, rValue, o_rStyleBase);
+ return;
+ }
+ if(!rValue.has<OUString>())
+ throw lang::IllegalArgumentException();
+ // special handling for RES_PAGEDESC
+ SfxItemSet& rStyleSet = o_rStyleBase.GetItemSet();
+ std::unique_ptr<SwFormatPageDesc> pNewDesc;
+ const SfxPoolItem* pItem;
+ if(SfxItemState::SET == rStyleSet.GetItemState(RES_PAGEDESC, true, &pItem))
+ pNewDesc.reset(new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem)));
+ else
+ pNewDesc.reset(new SwFormatPageDesc);
+ const auto sValue(rValue.get<OUString>());
+ OUString sDescName;
+ SwStyleNameMapper::FillUIName(sValue, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true);
+ if(pNewDesc->GetPageDesc() && pNewDesc->GetPageDesc()->GetName() == sDescName)
+ return;
+ if(sDescName.isEmpty())
+ {
+ rStyleSet.ClearItem(RES_BREAK);
+ rStyleSet.Put(SwFormatPageDesc());
+ }
+ else
+ {
+ SwPageDesc* pPageDesc(SwPageDesc::GetByName(*m_pDoc, sDescName));
+ if(!pPageDesc)
+ throw lang::IllegalArgumentException();
+ pNewDesc->RegisterToPageDesc(*pPageDesc);
+ rStyleSet.Put(*pNewDesc);
+ }
+}
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)
{
@@ -1670,55 +1706,10 @@ void SwXStyle::SetStyleProperty(const SfxItemPropertySimpleEntry& rEntry, const
SetPropertyValue<FN_UNO_FOLLOW_STYLE>(rEntry, rPropSet, rValue, rBase);
bDone = true;
break;
- case RES_PAGEDESC :
- {
- if (MID_PAGEDESC_PAGEDESCNAME != nMemberId)
- break;
- // special handling for RES_PAGEDESC
- if(aValue.getValueType() != ::cppu::UnoType<OUString>::get())
- throw lang::IllegalArgumentException();
- SfxItemSet& rStyleSet = rBase.GetItemSet();
-
- std::unique_ptr<SwFormatPageDesc> pNewDesc;
- const SfxPoolItem* pItem;
- if(SfxItemState::SET == rStyleSet.GetItemState( RES_PAGEDESC, true, &pItem ) )
- {
- pNewDesc.reset( new SwFormatPageDesc(*static_cast<const SwFormatPageDesc*>(pItem)) );
- }
- else
- pNewDesc.reset( new SwFormatPageDesc );
- OUString uDescName;
- aValue >>= uDescName;
- OUString sDescName;
- SwStyleNameMapper::FillUIName(uDescName, sDescName, nsSwGetPoolIdFromName::GET_POOLID_PAGEDESC, true );
- if(!pNewDesc->GetPageDesc() || pNewDesc->GetPageDesc()->GetName() != sDescName)
- {
- bool bPut = false;
- if (!sDescName.isEmpty())
- {
- SwPageDesc* pPageDesc = SwPageDesc::GetByName(*pDoc, sDescName);
- if(pPageDesc)
- {
- pNewDesc->RegisterToPageDesc( *pPageDesc );
- bPut = true;
- }
- else
- {
- throw lang::IllegalArgumentException();
- }
- }
- if(!bPut)
- {
- rStyleSet.ClearItem(RES_BREAK);
- rStyleSet.Put(SwFormatPageDesc());
- }
- else
- rStyleSet.Put(*pNewDesc);
-
- }
+ case RES_PAGEDESC:
+ SetPropertyValue<RES_PAGEDESC>(rEntry, rPropSet, rValue, rBase);
bDone = true;
break;
- }
case RES_TEXT_VERT_ADJUST:
{
if( pDoc )