diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-10-02 12:47:08 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-10-02 13:20:50 +0200 |
commit | 741dd512af5bd448c231cbd945e545cd79377858 (patch) | |
tree | d20d90dc5d3f65baa8f4cb027d80e5b33b18cf28 /sw | |
parent | e17db9f50e3a50b656dc8234330b61f30313e8fa (diff) |
SwXPageStyle: make sure SHARED_FIRST is added to both HEADER and FOOTER sets
It makes no sense to alter only the header set, as this property affects
both.
Change-Id: I7a34f97d144f877f808506e6ed961745994bb9a1
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 68 |
1 files changed, 41 insertions, 27 deletions
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index a851413e8641..5f965ba58eda 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2948,6 +2948,39 @@ SwXPageStyle::~SwXPageStyle() } +void lcl_putItemToSet(const SvxSetItem* pSetItem, sal_uInt16 nRes, sal_uInt16 nItemType, const uno::Any& rVal, sal_uInt8 nMemberId, SwStyleBase_Impl& rBaseImpl) +{ + SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone(); + SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); + const SfxPoolItem* pItem = 0; + SfxPoolItem* pNewItem = 0; + rSetSet.GetItemState(nRes, sal_True, &pItem); + if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes)) + pItem = &rSetSet.GetPool()->GetDefaultItem(nRes); + if(pItem) + { + pNewItem = pItem->Clone(); + } + else + { + switch(nItemType) + { + case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes); break; + case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes); break; + case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes); break; + case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break; + case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes); break; + case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break; + case TYPE_BOX: pNewItem = new SvxBoxItem(nRes); break; + } + } + pNewItem->PutValue(rVal, nMemberId); + rSetSet.Put(*pNewItem); + rBaseImpl.GetItemSet().Put(*pNewSetItem); + delete pNewItem; + delete pNewSetItem; +} + void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( const uno::Sequence< OUString >& rPropertyNames, const uno::Sequence< uno::Any >& rValues ) @@ -3067,35 +3100,16 @@ void SAL_CALL SwXPageStyle::SetPropertyValues_Impl( bFooter ? SID_ATTR_PAGE_FOOTERSET : SID_ATTR_PAGE_HEADERSET, sal_False, (const SfxPoolItem**)&pSetItem)) { - SvxSetItem* pNewSetItem = (SvxSetItem*)pSetItem->Clone(); - SfxItemSet& rSetSet = pNewSetItem->GetItemSet(); - const SfxPoolItem* pItem = 0; - SfxPoolItem* pNewItem = 0; - rSetSet.GetItemState(nRes, sal_True, &pItem); - if(!pItem && nRes != rSetSet.GetPool()->GetSlotId(nRes)) - pItem = &rSetSet.GetPool()->GetDefaultItem(nRes); - if(pItem) - { - pNewItem = pItem->Clone(); - } - else + lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl); + + if (nRes == SID_ATTR_PAGE_SHARED_FIRST) { - switch(nItemType) - { - case TYPE_BOOL: pNewItem = new SfxBoolItem(nRes); break; - case TYPE_SIZE: pNewItem = new SvxSizeItem(nRes); break; - case TYPE_BRUSH: pNewItem = new SvxBrushItem(nRes); break; - case TYPE_ULSPACE: pNewItem = new SvxULSpaceItem(nRes); break; - case TYPE_SHADOW : pNewItem = new SvxShadowItem(nRes); break; - case TYPE_LRSPACE: pNewItem = new SvxLRSpaceItem(nRes); break; - case TYPE_BOX: pNewItem = new SvxBoxItem(nRes); break; - } + // Need to add this to the other as well + if (SFX_ITEM_SET == aBaseImpl.GetItemSet().GetItemState( + bFooter ? SID_ATTR_PAGE_HEADERSET : SID_ATTR_PAGE_FOOTERSET, + sal_False, (const SfxPoolItem**)&pSetItem)) + lcl_putItemToSet(pSetItem, nRes, nItemType, pValues[nProp], pEntry->nMemberId, aBaseImpl); } - pNewItem->PutValue(pValues[nProp], pEntry->nMemberId); - rSetSet.Put(*pNewItem); - aBaseImpl.GetItemSet().Put(*pNewSetItem); - delete pNewItem; - delete pNewSetItem; } else if(SID_ATTR_PAGE_ON == nRes ) { |