summaryrefslogtreecommitdiff
path: root/sw/source
diff options
context:
space:
mode:
authorArmin Le Grand (Allotropia) <armin.le.grand@me.com>2021-06-11 12:06:27 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2021-06-11 16:58:27 +0200
commiteb0222e80ba6f5b7b11f1e43f3723162beb2ba71 (patch)
treef5044a65b9c5f426c5ab344f45eed4d7ba5ca6c4 /sw/source
parent64378ded7b87fa785f13b998e006d87f44a2776d (diff)
tdf#130428 remove unnecessary usage of SfxItemState::UNKNOWN
The mechanism around NUMRULE_STATE does only do something when the SfxItemState is actually SfxItemState::SET, so this can be reduced to use a valid Item shared_ptr when this is the case Change-Id: I973648abff3696057f2ca21608ed64570742dddb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117043 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com> Tested-by: Jenkins
Diffstat (limited to 'sw/source')
-rw-r--r--sw/source/core/doc/DocumentContentOperationsManager.cxx39
1 files changed, 18 insertions, 21 deletions
diff --git a/sw/source/core/doc/DocumentContentOperationsManager.cxx b/sw/source/core/doc/DocumentContentOperationsManager.cxx
index 44c5c9ded7f9..2f1818a64a15 100644
--- a/sw/source/core/doc/DocumentContentOperationsManager.cxx
+++ b/sw/source/core/doc/DocumentContentOperationsManager.cxx
@@ -4571,20 +4571,18 @@ SwFlyFrameFormat* DocumentContentOperationsManager::InsNoTextNode( const SwPosit
}
#define NUMRULE_STATE \
- SfxItemState aNumRuleState = SfxItemState::UNKNOWN; \
- std::shared_ptr<SwNumRuleItem> aNumRuleItem; \
- SfxItemState aListIdState = SfxItemState::UNKNOWN; \
- std::shared_ptr<SfxStringItem> aListIdItem; \
+ std::shared_ptr<SwNumRuleItem> aNumRuleItemHolderIfSet; \
+ std::shared_ptr<SfxStringItem> aListIdItemHolderIfSet; \
#define PUSH_NUMRULE_STATE \
- lcl_PushNumruleState( aNumRuleState, aNumRuleItem, aListIdState, aListIdItem, pDestTextNd );
+ lcl_PushNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd );
#define POP_NUMRULE_STATE \
- lcl_PopNumruleState( aNumRuleState, aNumRuleItem, aListIdState, aListIdItem, pDestTextNd, rPam );
+ lcl_PopNumruleState( aNumRuleItemHolderIfSet, aListIdItemHolderIfSet, pDestTextNd, rPam );
static void lcl_PushNumruleState(
- SfxItemState &aNumRuleState, std::shared_ptr<SwNumRuleItem>& aNumRuleItem,
- SfxItemState &aListIdState, std::shared_ptr<SfxStringItem>& aListIdItem,
+ std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
+ std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
const SwTextNode *pDestTextNd )
{
// Safe numrule item at destination.
@@ -4593,23 +4591,21 @@ static void lcl_PushNumruleState(
if (pAttrSet == nullptr)
return;
- const SfxPoolItem * pItem = nullptr;
- aNumRuleState = pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem);
- if (SfxItemState::SET == aNumRuleState)
+ const SfxPoolItem* pItem(nullptr);
+ if (SfxItemState::SET == pAttrSet->GetItemState(RES_PARATR_NUMRULE, false, &pItem))
{
- aNumRuleItem.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_NUMRULE));
+ aNumRuleItemHolderIfSet.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_NUMRULE));
}
- aListIdState = pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem);
- if (SfxItemState::SET == aListIdState)
+ if (SfxItemState::SET == pAttrSet->GetItemState(RES_PARATR_LIST_ID, false, &pItem))
{
- aListIdItem.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_LIST_ID));
+ aListIdItemHolderIfSet.reset(&pItem->Clone()->StaticWhichCast(RES_PARATR_LIST_ID));
}
}
static void lcl_PopNumruleState(
- SfxItemState aNumRuleState, const std::shared_ptr<SwNumRuleItem>& aNumRuleItem,
- SfxItemState aListIdState, const std::shared_ptr<SfxStringItem>& aListIdItem,
+ std::shared_ptr<SwNumRuleItem>& aNumRuleItemHolderIfSet,
+ std::shared_ptr<SfxStringItem>& aListIdItemHolderIfSet,
SwTextNode *pDestTextNd, const SwPaM& rPam )
{
/* If only a part of one paragraph is copied
@@ -4618,17 +4614,18 @@ static void lcl_PopNumruleState(
if ( lcl_MarksWholeNode(rPam) )
return;
- if (SfxItemState::SET == aNumRuleState)
+ if (aNumRuleItemHolderIfSet)
{
- pDestTextNd->SetAttr(*aNumRuleItem);
+ pDestTextNd->SetAttr(*aNumRuleItemHolderIfSet);
}
else
{
pDestTextNd->ResetAttr(RES_PARATR_NUMRULE);
}
- if (SfxItemState::SET == aListIdState)
+
+ if (aListIdItemHolderIfSet)
{
- pDestTextNd->SetAttr(*aListIdItem);
+ pDestTextNd->SetAttr(*aListIdItemHolderIfSet);
}
else
{