[Libreoffice-commits] core.git: 2 commits - sfx2/source sw/source
Armin Le Grand (Allotropia) (via logerrit)
logerrit at kemper.freedesktop.org
Fri Jun 11 14:59:03 UTC 2021
sfx2/source/control/request.cxx | 13 +++--
sw/source/core/doc/DocumentContentOperationsManager.cxx | 39 +++++++---------
2 files changed, 26 insertions(+), 26 deletions(-)
New commits:
commit eb0222e80ba6f5b7b11f1e43f3723162beb2ba71
Author: Armin Le Grand (Allotropia) <armin.le.grand at me.com>
AuthorDate: Fri Jun 11 12:06:27 2021 +0200
Commit: Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Fri Jun 11 16:58:27 2021 +0200
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 at collabora.co.uk>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
Tested-by: Jenkins
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
{
commit 64378ded7b87fa785f13b998e006d87f44a2776d
Author: Armin Le Grand (Allotropia) <armin.le.grand at me.com>
AuthorDate: Fri Jun 11 10:57:32 2021 +0200
Commit: Armin Le Grand <Armin.Le.Grand at me.com>
CommitDate: Fri Jun 11 16:58:18 2021 +0200
tdf#130428 remove unnecessary usage of SfxItemState::UNKNOWN
Another place where SfxItemState::UNKNOWN was used as placeholder
Change-Id: Ie2757e8356bfea7010b0442d72ef7865cbb18d5d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117034
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
Reviewed-by: Armin Le Grand <Armin.Le.Grand at me.com>
Tested-by: Jenkins
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index 277c5745b50c..cac6ad5175a0 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -592,14 +592,17 @@ void SfxRequest::Done_Impl
if ( !pImpl->pSlot->IsMode(SfxSlotMode::METHOD) )
{
// get the property as SfxPoolItem
- const SfxPoolItem *pItem;
- sal_uInt16 nWhich = rPool.GetWhich(pImpl->pSlot->GetSlotId());
- SfxItemState eState = pSet ? pSet->GetItemState( nWhich, false, &pItem ) : SfxItemState::UNKNOWN;
- SAL_WARN_IF( SfxItemState::SET != eState, "sfx", "Recording property not available: "
+ const SfxPoolItem *pItem(nullptr);
+ const sal_uInt16 nWhich(rPool.GetWhich(pImpl->pSlot->GetSlotId()));
+ const bool bItemStateSet(nullptr != pSet);
+ const SfxItemState eState(bItemStateSet ? pSet->GetItemState( nWhich, false, &pItem ) : SfxItemState::DEFAULT);
+ SAL_WARN_IF( !bItemStateSet || SfxItemState::SET != eState, "sfx", "Recording property not available: "
<< pImpl->pSlot->GetSlotId() );
uno::Sequence < beans::PropertyValue > aSeq;
- if ( eState == SfxItemState::SET )
+
+ if ( bItemStateSet && SfxItemState::SET == eState )
TransformItems( pImpl->pSlot->GetSlotId(), *pSet, aSeq, pImpl->pSlot );
+
pImpl->Record( aSeq );
}
More information about the Libreoffice-commits
mailing list