cui/source/tabpages/numfmt.cxx          |   10 +------
 editeng/source/editeng/impedit5.cxx     |   11 ++++----
 editeng/source/uno/unotext.cxx          |    7 +++--
 reportdesign/source/ui/misc/UITools.cxx |    4 +--
 sc/source/core/data/documen4.cxx        |    5 ++-
 sc/source/core/data/table4.cxx          |    5 ++-
 sc/source/ui/unoobj/docuno.cxx          |    7 +++--
 sc/source/ui/view/viewdata.cxx          |    7 +++--
 sd/source/filter/html/htmlex.cxx        |   15 ++++-------
 sd/source/filter/xml/sdtransform.cxx    |   10 ++++---
 sd/source/ui/dlg/dlgolbul.cxx           |   10 +++----
 sd/source/ui/func/fuolbull.cxx          |    4 +--
 sd/source/ui/func/futempl.cxx           |   27 ++++++++------------
 sd/source/ui/view/outlview.cxx          |    5 ++-
 sd/source/ui/view/viewshel.cxx          |    4 +--
 svx/source/form/fmtextcontrolshell.cxx  |    5 +--
 svx/source/toolbars/extrusionbar.cxx    |   42 +++++++++++++++++++-------------
 svx/source/toolbars/fontworkbar.cxx     |   15 ++++++-----
 sw/source/core/crsr/viscrs.cxx          |    5 ++-
 sw/source/core/text/txtfld.cxx          |    5 ++-
 sw/source/filter/ww8/ww8atr.cxx         |    4 +--
 21 files changed, 108 insertions(+), 99 deletions(-)

New commits:
commit a1be5ede8e7a8042683efa10b823d952e1bd9513
Author:     Noel Grandin <[email protected]>
AuthorDate: Wed Jul 31 07:41:52 2024 +0200
Commit:     Noel Grandin <[email protected]>
CommitDate: Wed Jul 31 09:54:12 2024 +0200

    reduce number of GetItem calls
    
    if we already call GetItemState, we can use that call to fetch the item
    
    Change-Id: I736dec9bb56ad3bd66bb53e1cef2cf1e3092821d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171269
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>

diff --git a/cui/source/tabpages/numfmt.cxx b/cui/source/tabpages/numfmt.cxx
index 7eed6df2e241..584c7acdd5b0 100644
--- a/cui/source/tabpages/numfmt.cxx
+++ b/cui/source/tabpages/numfmt.cxx
@@ -420,12 +420,8 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet 
)
         }
     }
 
-    eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_SOURCE );
-
-    if ( eState == SfxItemState::SET )
+    if ( const SfxBoolItem* pBoolItem = rSet->GetItemIfSet( 
SID_ATTR_NUMBERFORMAT_SOURCE ))
     {
-        const SfxBoolItem* pBoolItem =
-                      GetItem( *rSet, SID_ATTR_NUMBERFORMAT_SOURCE );
         if ( pBoolItem )
             m_xCbSourceFormat->set_active(pBoolItem->GetValue());
         else
@@ -520,9 +516,7 @@ void SvxNumberFormatTabPage::Reset( const SfxItemSet* rSet )
     {
         SetCategory(nCatLbSelPos );
     }
-    eState = rSet->GetItemState( SID_ATTR_NUMBERFORMAT_ADD_AUTO );
-    if(SfxItemState::SET == eState)
-         pAutoEntryAttr = GetItem( *rSet, SID_ATTR_NUMBERFORMAT_ADD_AUTO );
+    pAutoEntryAttr = rSet->GetItemIfSet( SID_ATTR_NUMBERFORMAT_ADD_AUTO );
     // no_NO is an alias for nb_NO and normally isn't listed, we need it for
     // backwards compatibility, but only if the format passed is of
     // LanguageType no_NO.
diff --git a/editeng/source/editeng/impedit5.cxx 
b/editeng/source/editeng/impedit5.cxx
index 5a1a9bb66d48..fff6d21d8373 100644
--- a/editeng/source/editeng/impedit5.cxx
+++ b/editeng/source/editeng/impedit5.cxx
@@ -349,27 +349,28 @@ SfxItemSet ImpEditEngine::GetAttribs( EditSelection aSel, 
EditEngineAttribs nOnl
             {
                 if ( aCurSet.GetItemState( nWhich ) == SfxItemState::DEFAULT )
                 {
+                    const SfxPoolItem* pItem = nullptr;
                     if ( nOnlyHardAttrib == EditEngineAttribs::All )
                     {
                         const SfxPoolItem& rItem = 
pNode->GetContentAttribs().GetItem( nWhich );
                         aCurSet.Put( rItem );
                     }
-                    else if ( 
pNode->GetContentAttribs().GetItems().GetItemState( nWhich ) == 
SfxItemState::SET )
+                    else if ( 
pNode->GetContentAttribs().GetItems().GetItemState( nWhich, true, &pItem ) == 
SfxItemState::SET )
                     {
-                        const SfxPoolItem& rItem = 
pNode->GetContentAttribs().GetItems().Get( nWhich );
-                        aCurSet.Put( rItem );
+                        aCurSet.Put( *pItem );
                     }
                 }
                 else if ( aCurSet.GetItemState( nWhich ) == SfxItemState::SET )
                 {
                     const SfxPoolItem* pItem = nullptr;
+                    const SfxPoolItem* pTmpItem = nullptr;
                     if ( nOnlyHardAttrib == EditEngineAttribs::All )
                     {
                         pItem = &pNode->GetContentAttribs().GetItem( nWhich );
                     }
-                    else if ( 
pNode->GetContentAttribs().GetItems().GetItemState( nWhich ) == 
SfxItemState::SET )
+                    else if ( 
pNode->GetContentAttribs().GetItems().GetItemState( nWhich, true, &pTmpItem ) 
== SfxItemState::SET )
                     {
-                        pItem = &pNode->GetContentAttribs().GetItems().Get( 
nWhich );
+                        pItem = pTmpItem;
                     }
                     // pItem can only be NULL when nOnlyHardAttrib...
                     if ( !pItem || ( *pItem != aCurSet.Get( nWhich ) ) )
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index 9d70aee46828..ffb671c4837e 100644
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -646,9 +646,10 @@ void SvxUnoTextRangeBase::getPropertyValue( const 
SfxItemPropertyMapEntry* pMap,
     switch( pMap->nWID )
     {
     case EE_FEATURE_FIELD:
-        if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SfxItemState::SET 
)
+    {
+        const SvxFieldItem* pItem = nullptr;
+        if ( rSet.GetItemState( EE_FEATURE_FIELD, false, &pItem ) == 
SfxItemState::SET )
         {
-            const SvxFieldItem* pItem = rSet.GetItem<SvxFieldItem>( 
EE_FEATURE_FIELD );
             const SvxFieldData* pData = pItem->GetField();
             uno::Reference< text::XTextRange > xAnchor( this );
 
@@ -664,7 +665,7 @@ void SvxUnoTextRangeBase::getPropertyValue( const 
SfxItemPropertyMapEntry* pMap,
             rAny <<= xField;
         }
         break;
-
+    }
     case WID_PORTIONTYPE:
         if ( rSet.GetItemState( EE_FEATURE_FIELD, false ) == SfxItemState::SET 
)
         {
diff --git a/reportdesign/source/ui/misc/UITools.cxx 
b/reportdesign/source/ui/misc/UITools.cxx
index 02ae0243f04e..cbaad4ebd14a 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -304,11 +304,11 @@ namespace
         for (const auto & rPair : rPropertyMap.getPropertyEntries())
         {
             const SfxItemPropertyMapEntry* pProp = rPair.second;
-            if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID) && 
xInfo->hasPropertyByName(pProp->aName) )
+            const SfxPoolItem* pItem = nullptr;
+            if ( SfxItemState::SET == _rItemSet.GetItemState(pProp->nWID, 
true, &pItem) && xInfo->hasPropertyByName(pProp->aName) )
             {
                 if ( ( pProp->nFlags & beans::PropertyAttribute::READONLY ) != 
beans::PropertyAttribute::READONLY )
                 {
-                    const SfxPoolItem* pItem = _rItemSet.GetItem(pProp->nWID);
                     if ( pItem )
                     {
                         uno::Any aValue;
diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx
index 74a66449ec40..c450e698ecba 100644
--- a/sc/source/core/data/documen4.cxx
+++ b/sc/source/core/data/documen4.cxx
@@ -747,9 +747,10 @@ const SfxPoolItem* ScDocument::GetEffItem(
     if ( pPattern )
     {
         const SfxItemSet& rSet = pPattern->GetItemSet();
-        if ( rSet.GetItemState( ATTR_CONDITIONAL ) == SfxItemState::SET )
+        const ScCondFormatItem* pConditionalItem = nullptr;
+        if ( rSet.GetItemState( ATTR_CONDITIONAL, true, &pConditionalItem ) == 
SfxItemState::SET )
         {
-            const ScCondFormatIndexes& rIndex = 
pPattern->GetItem(ATTR_CONDITIONAL).GetCondFormatData();
+            const ScCondFormatIndexes& rIndex = 
pConditionalItem->GetCondFormatData();
             ScConditionalFormatList* pCondFormList = GetCondFormList( nTab );
             if (!rIndex.empty() && pCondFormList)
             {
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index a400762d1ca2..56588d6df5fb 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -279,9 +279,10 @@ void ScTable::FillAnalyse( SCCOL nCol1, SCROW nRow1, SCCOL 
nCol2, SCROW nRow2,
         for (SCSIZE i = 0; i < nCount; ++i)
         {
             const ScPatternAttr* pPattern = GetPattern(nColCurr, nRowCurr);
+            const ScMergeFlagAttr* pMergeFlagItem = nullptr;
             bool bOverlapped
-                = pPattern->GetItemSet().GetItemState(ATTR_MERGE_FLAG, false) 
== SfxItemState::SET
-                  && pPattern->GetItem(ATTR_MERGE_FLAG).IsOverlapped();
+                = pPattern->GetItemSet().GetItemState(ATTR_MERGE_FLAG, false, 
&pMergeFlagItem) == SfxItemState::SET
+                  && pMergeFlagItem->IsOverlapped();
 
             if (bOverlapped)
                 bHasOverlappedCells = true;
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 421733bfecdb..24f9a5270361 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1237,12 +1237,13 @@ OString ScPostIt::NoteRangeToJsonString(const 
ScDocument& rDoc, const ScAddress&
     SCROW nY(rPos.Row());
     OString aStartCellAddress(OString::number(nX) + " " + OString::number(nY));
     const ScPatternAttr* pMarkPattern = rDoc.GetPattern(nX, nY, rPos.Tab());
-    if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, 
false) == SfxItemState::SET)
+    const ScMergeAttr* pMergeItem = nullptr;
+    if (pMarkPattern && pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, 
false, &pMergeItem) == SfxItemState::SET)
     {
-        SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge();
+        SCCOL nCol = pMergeItem->GetColMerge();
         if (nCol > 1)
             nX += nCol - 1;
-        SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge();
+        SCROW nRow = pMergeItem->GetRowMerge();
         if (nRow > 1)
             nY += nRow - 1;
     }
diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx
index 40e9ce7a9d5a..102c7ad9adb1 100644
--- a/sc/source/ui/view/viewdata.cxx
+++ b/sc/source/ui/view/viewdata.cxx
@@ -1158,10 +1158,11 @@ ScMarkType ScViewData::GetSimpleArea( ScRange & rRange, 
ScMarkData & rNewMark )
         if (eMarkType == SC_MARK_NONE)
             eMarkType = SC_MARK_SIMPLE;
         const ScPatternAttr* pMarkPattern = mrDoc.GetPattern(GetCurX(), 
GetCurY(), GetTabNo());
-        if (pMarkPattern && 
pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false) == SfxItemState::SET)
+        const ScMergeAttr* pMergeItem = nullptr;
+        if (pMarkPattern && 
pMarkPattern->GetItemSet().GetItemState(ATTR_MERGE, false, &pMergeItem) == 
SfxItemState::SET)
         {
-            SCROW nRow = pMarkPattern->GetItem(ATTR_MERGE).GetRowMerge();
-            SCCOL nCol = pMarkPattern->GetItem(ATTR_MERGE).GetColMerge();
+            SCROW nRow = pMergeItem->GetRowMerge();
+            SCCOL nCol = pMergeItem->GetColMerge();
             if ( nRow < 1 || nCol < 1 )
             {
                 // This kind of cells do exist. Not sure if that is intended 
or a bug.
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index c670e2467b27..d64005a44710 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -306,17 +306,14 @@ OUString TextAttribToHTMLString( SfxItemSet const * pSet, 
HtmlState* pState )
         return OUString();
 
     OUString aLink, aTarget;
-    if ( pSet->GetItemState( EE_FEATURE_FIELD ) == SfxItemState::SET )
+    const SvxFieldItem* pItem = nullptr;
+    if ( pSet->GetItemState( EE_FEATURE_FIELD, true, &pItem ) == 
SfxItemState::SET )
     {
-        const SvxFieldItem* pItem = pSet->GetItem<SvxFieldItem>( 
EE_FEATURE_FIELD );
-        if(pItem)
+        const SvxURLField* pURL = dynamic_cast<const SvxURLField*>( 
pItem->GetField() );
+        if(pURL)
         {
-            const SvxURLField* pURL = dynamic_cast<const SvxURLField*>( 
pItem->GetField() );
-            if(pURL)
-            {
-                aLink = pURL->GetURL();
-                aTarget = pURL->GetTargetFrame();
-            }
+            aLink = pURL->GetURL();
+            aTarget = pURL->GetTargetFrame();
         }
     }
 
diff --git a/sd/source/filter/xml/sdtransform.cxx 
b/sd/source/filter/xml/sdtransform.cxx
index 50237d72b67f..3049935c9128 100644
--- a/sd/source/filter/xml/sdtransform.cxx
+++ b/sd/source/filter/xml/sdtransform.cxx
@@ -267,9 +267,10 @@ bool SdTransformOOo2xDocument::getBulletState( const 
SfxItemSet& rSet, SfxStyleS
 
 bool SdTransformOOo2xDocument::getBulletState( const SfxItemSet& rSet, 
sal_uInt16 nWhich, bool& rState )
 {
-    if( rSet.GetItemState( nWhich ) == SfxItemState::SET )
+    const SfxPoolItem* pItem = nullptr;
+    if( rSet.GetItemState( nWhich, true, &pItem ) == SfxItemState::SET )
     {
-        const SvXMLAttrContainerItem& rAttr = 
*rSet.GetItem<SvXMLAttrContainerItem>( nWhich );
+        const SvXMLAttrContainerItem& rAttr = *static_cast<const 
SvXMLAttrContainerItem*>( pItem );
 
         const sal_uInt16 nCount = rAttr.GetAttrCount();
         for( sal_uInt16 nItem = 0; nItem < nCount; nItem++ )
@@ -314,9 +315,10 @@ bool SdTransformOOo2xDocument::removeAlienAttributes( 
SfxItemSet& rSet )
 
 bool SdTransformOOo2xDocument::removeAlienAttributes( SfxItemSet& rSet, 
sal_uInt16 nWhich )
 {
-    if( rSet.GetItemState( nWhich ) == SfxItemState::SET )
+    const SfxPoolItem* pItem = nullptr;
+    if( rSet.GetItemState( nWhich, true, &pItem ) == SfxItemState::SET )
     {
-        const SvXMLAttrContainerItem& rAttr = 
*rSet.GetItem<SvXMLAttrContainerItem>( nWhich );
+        const SvXMLAttrContainerItem& rAttr = *static_cast<const 
SvXMLAttrContainerItem*>( pItem );
 
         const sal_uInt16 nCount = rAttr.GetAttrCount();
         for( sal_uInt16 nItem = 0; nItem < nCount; nItem++ )
diff --git a/sd/source/ui/dlg/dlgolbul.cxx b/sd/source/ui/dlg/dlgolbul.cxx
index bd36f885da52..d09991fdca87 100644
--- a/sd/source/ui/dlg/dlgolbul.cxx
+++ b/sd/source/ui/dlg/dlgolbul.cxx
@@ -101,10 +101,10 @@ OutlineBulletDlg::OutlineBulletDlg(weld::Window* pParent, 
const SfxItemSet* pAtt
         m_aInputSet.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
     }
 
-    if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET) == 
SfxItemState::SET )
+    const SvxNumBulletItem* pBulletItem = nullptr;
+    if (m_bTitle && m_aInputSet.GetItemState(EE_PARA_NUMBULLET, true, 
&pBulletItem) == SfxItemState::SET )
     {
-        const SvxNumBulletItem* pItem = 
m_aInputSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET);
-        const SvxNumRule& rRule = pItem->GetNumRule();
+        const SvxNumRule& rRule = pBulletItem->GetNumRule();
         SvxNumRule aNewRule( rRule );
         aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
 
@@ -157,9 +157,9 @@ const SfxItemSet* 
OutlineBulletDlg::GetBulletOutputItemSet() const
         // #i35937 - removed EE_PARA_BULLETSTATE setting
     }
 
-    if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET) == 
SfxItemState::SET)
+    const SvxNumBulletItem* pBulletItem = nullptr;
+    if (m_bTitle && m_xOutputSet->GetItemState(EE_PARA_NUMBULLET, true, 
&pBulletItem) == SfxItemState::SET)
     {
-        const SvxNumBulletItem* pBulletItem = 
m_xOutputSet->GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET);
         SvxNumRule& rRule = const_cast<SvxNumRule&>(pBulletItem->GetNumRule());
         rRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS, false );
     }
diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx
index 8c8fc850648c..f9b8f3965c36 100644
--- a/sd/source/ui/func/fuolbull.cxx
+++ b/sd/source/ui/func/fuolbull.cxx
@@ -321,9 +321,9 @@ const SvxNumBulletItem* 
FuBulletAndPosition::GetNumBulletItem(SfxItemSet& aNewAt
 
     aNewAttr.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
 
-    if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET 
)
+    const SvxNumBulletItem* pBulletItem = nullptr;
+    if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) 
== SfxItemState::SET )
     {
-        const SvxNumBulletItem* pBulletItem = 
aNewAttr.GetItem(EE_PARA_NUMBULLET);
         const SvxNumRule& rLclRule = pBulletItem->GetNumRule();
         SvxNumRule aNewRule( rLclRule );
         aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
diff --git a/sd/source/ui/func/futempl.cxx b/sd/source/ui/func/futempl.cxx
index 83a895c1449e..d670c706f182 100644
--- a/sd/source/ui/func/futempl.cxx
+++ b/sd/source/ui/func/futempl.cxx
@@ -406,9 +406,10 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                             // EE_PARA_NUMBULLET item is only valid in first 
outline template
                             if( (ePO >= PresentationObjects::Outline_2) && 
(ePO <= PresentationObjects::Outline_9) )
                             {
-                                if (aTempSet.GetItemState(EE_PARA_NUMBULLET) 
== SfxItemState::SET)
+                                const SvxNumBulletItem* pBulletItem = nullptr;
+                                if (aTempSet.GetItemState(EE_PARA_NUMBULLET, 
true, &pBulletItem) == SfxItemState::SET)
                                 {
-                                    SvxNumRule 
aRule(aTempSet.GetItem<SvxNumBulletItem>(EE_PARA_NUMBULLET)->GetNumRule());
+                                    SvxNumRule 
aRule(pBulletItem->GetNumRule());
 
                                     OUString 
sStyleName(SdResId(STR_PSEUDOSHEET_OUTLINE) + " 1");
                                     SfxStyleSheetBase* pFirstStyleSheet = 
pSSPool->Find( sStyleName, SfxStyleFamily::Pseudo);
@@ -433,63 +434,57 @@ void FuTemplate::DoExecute( SfxRequest& rReq )
                         sdr::properties::CleanupFillProperties( rAttr );
 
                         // check for unique names of named items for xml
-                        if( rAttr.GetItemState( XATTR_FILLBITMAP ) == 
SfxItemState::SET )
+                        const SfxPoolItem* pOldItem = nullptr;
+                        if( rAttr.GetItemState( XATTR_FILLBITMAP, true, 
&pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_FILLBITMAP );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XFillBitmapItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_LINEDASH ) == 
SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_LINEDASH, true, 
&pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_LINEDASH );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XLineDashItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_LINESTART ) == 
SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_LINESTART, true, 
&pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_LINESTART );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XLineStartItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_LINEEND ) == 
SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_LINEEND, true, &pOldItem 
) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_LINEEND );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XLineEndItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_FILLGRADIENT ) == 
SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_FILLGRADIENT, true, 
&pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_FILLGRADIENT );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XFillGradientItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE ) 
== SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_FILLFLOATTRANSPARENCE, 
true, &pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_FILLFLOATTRANSPARENCE );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XFillFloatTransparenceItem*>(pOldItem)->checkForUniqueItem( 
*mpDoc );
                             if( pNewItem )
                             {
                                 rAttr.Put( std::move(pNewItem) );
                             }
                         }
-                        if( rAttr.GetItemState( XATTR_FILLHATCH ) == 
SfxItemState::SET )
+                        if( rAttr.GetItemState( XATTR_FILLHATCH, true, 
&pOldItem ) == SfxItemState::SET )
                         {
-                            const SfxPoolItem* pOldItem = rAttr.GetItem( 
XATTR_FILLHATCH );
                             std::unique_ptr<SfxPoolItem> pNewItem = 
static_cast<const XFillHatchItem*>(pOldItem)->checkForUniqueItem( *mpDoc );
                             if( pNewItem )
                             {
diff --git a/sd/source/ui/view/outlview.cxx b/sd/source/ui/view/outlview.cxx
index c781d710c877..07c55d7c3ee7 100644
--- a/sd/source/ui/view/outlview.cxx
+++ b/sd/source/ui/view/outlview.cxx
@@ -707,11 +707,12 @@ IMPL_LINK( OutlineView, DepthChangedHdl, 
::Outliner::DepthChangeHdlParam, aParam
     pOutliner->SetStyleSheet( nPara, pStyleSheet );
 
     // restore the old bullet item but not if the style changed
+    const SvxNumBulletItem* pBulletItem = nullptr;
     if ( pOutliner->GetPrevDepth() != -1 && nDepth != -1 &&
-         aOldAttrs.GetItemState( EE_PARA_NUMBULLET ) == SfxItemState::SET )
+         aOldAttrs.GetItemState( EE_PARA_NUMBULLET, true, &pBulletItem ) == 
SfxItemState::SET )
     {
         SfxItemSet aAttrs( pOutliner->GetParaAttribs( nPara ) );
-        aAttrs.Put( *aOldAttrs.GetItem( EE_PARA_NUMBULLET ) );
+        aAttrs.Put( *pBulletItem );
         pOutliner->SetParaAttribs( nPara, aAttrs );
     }
 }
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index d140187d56d6..c90788a284ec 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -1020,9 +1020,9 @@ const SvxNumBulletItem* 
ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, TypedW
 
     aNewAttr.Put(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
 
-    if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET 
)
+    const SvxNumBulletItem* pBulletItem = nullptr;
+    if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET, true, &pBulletItem) 
== SfxItemState::SET )
     {
-        const SvxNumBulletItem* pBulletItem = 
aNewAttr.GetItem(EE_PARA_NUMBULLET);
         const SvxNumRule& rRule = pBulletItem->GetNumRule();
         SvxNumRule aNewRule( rRule );
         aNewRule.SetFeatureFlag( SvxNumRuleFlags::NO_NUMBERS );
diff --git a/svx/source/form/fmtextcontrolshell.cxx 
b/svx/source/form/fmtextcontrolshell.cxx
index e8f8dc8de195..4cae4ae8a502 100644
--- a/svx/source/form/fmtextcontrolshell.cxx
+++ b/svx/source/form/fmtextcontrolshell.cxx
@@ -639,11 +639,10 @@ namespace svx
             const SfxItemSet& rModifiedItems = *xDialog->GetOutputItemSet();
             for ( WhichId nWhich = pPool->GetFirstWhich(); nWhich <= 
pPool->GetLastWhich(); ++nWhich )
             {
-                if ( rModifiedItems.GetItemState( nWhich ) == 
SfxItemState::SET )
+                const SfxPoolItem* pModifiedItem = nullptr;
+                if ( rModifiedItems.GetItemState( nWhich, true, &pModifiedItem 
) == SfxItemState::SET )
                 {
                     SfxSlotId nSlotForItemSet = pPool->GetSlotId( nWhich );
-                    const SfxPoolItem* pModifiedItem = rModifiedItems.GetItem( 
nWhich );
-
 
                     SfxSlotId nSlotForDispatcher = nSlotForItemSet;
                     switch ( nSlotForDispatcher )
diff --git a/svx/source/toolbars/extrusionbar.cxx 
b/svx/source/toolbars/extrusionbar.cxx
index 8d7424064b52..c4832775a5a7 100644
--- a/svx/source/toolbars/extrusionbar.cxx
+++ b/svx/source/toolbars/extrusionbar.cxx
@@ -198,9 +198,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
 
     case SID_EXTRUSION_DIRECTION:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_DIRECTION ) == SfxItemState::SET )
+        const SfxInt32Item* pExtrusionItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_DIRECTION, true, &pExtrusionItem ) == SfxItemState::SET )
         {
-            sal_Int32 nSkew = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_DIRECTION)->GetValue();
+            sal_Int32 nSkew = pExtrusionItem->GetValue();
 
             Position3D  aViewPoint( 3472, -3472, 25000 );
             double      fOriginX = 0.50;
@@ -282,9 +283,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
     break;
     case SID_EXTRUSION_PROJECTION:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_PROJECTION ) == SfxItemState::SET )
+        const SfxInt32Item* pExtrusionItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_PROJECTION, true, &pExtrusionItem ) == SfxItemState::SET )
         {
-            sal_Int32 nProjection = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_PROJECTION)->GetValue();
+            sal_Int32 nProjection = pExtrusionItem->GetValue();
             ProjectionMode eProjectionMode = nProjection == 1 ? 
ProjectionMode_PARALLEL : ProjectionMode_PERSPECTIVE;
             css::beans::PropertyValue aPropValue;
             aPropValue.Name = "ProjectionMode";
@@ -295,9 +297,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
     break;
     case SID_EXTRUSION_DEPTH:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_DEPTH ) == SfxItemState::SET)
+        const SvxDoubleItem* pExtrusionItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_DEPTH, true, &pExtrusionItem ) == SfxItemState::SET)
         {
-            double fDepth = 
rReq.GetArgs()->GetItem<SvxDoubleItem>(SID_EXTRUSION_DEPTH)->GetValue();
+            double fDepth = pExtrusionItem->GetValue();
             EnhancedCustomShapeParameterPair aDepthPropPair;
             aDepthPropPair.First.Value <<= fDepth;
             aDepthPropPair.First.Type = 
EnhancedCustomShapeParameterType::NORMAL;
@@ -338,9 +341,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
     break;
     case SID_EXTRUSION_SURFACE:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_SURFACE ) == SfxItemState::SET)
+        const SfxInt32Item* pExtrusionItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_SURFACE, true, &pExtrusionItem ) == SfxItemState::SET)
         {
-            sal_Int32 nSurface = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_SURFACE)->GetValue();
+            sal_Int32 nSurface = pExtrusionItem->GetValue();
 
             // Set ShadeMode only when changing from or to wireframe, 
otherwise keep existing value.
             ShadeMode eOldShadeMode(ShadeMode_FLAT);
@@ -443,9 +447,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
     break;
     case SID_EXTRUSION_LIGHTING_INTENSITY:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_LIGHTING_INTENSITY ) == SfxItemState::SET)
+        const SfxInt32Item* pLightItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_LIGHTING_INTENSITY, true, &pLightItem ) == SfxItemState::SET)
         {
-            sal_Int32 nLevel = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_LIGHTING_INTENSITY)->GetValue();
+            sal_Int32 nLevel = pLightItem->GetValue();
 
             double fBrightness; // c3DAmbientIntensity in MS Office
             double fLevel1; // c3DKeyIntensity in MS Office
@@ -494,9 +499,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
     break;
     case SID_EXTRUSION_LIGHTING_DIRECTION:
     {
-        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_LIGHTING_DIRECTION ) == SfxItemState::SET)
+        const SfxInt32Item* pLightDirectionItem = nullptr;
+        if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_EXTRUSION_LIGHTING_DIRECTION, true, &pLightDirectionItem ) == 
SfxItemState::SET)
         {
-            sal_Int32 nDirection = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_EXTRUSION_LIGHTING_DIRECTION)->GetValue();
+            sal_Int32 nDirection = pLightDirectionItem->GetValue();
 
             if((nDirection >= 0) && (nDirection < 9))
             {
@@ -635,12 +641,15 @@ void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest 
const & rReq, SfxBindi
         break;
 
         case SID_EXTRUSION_DEPTH_DIALOG:
+        {
+            const SvxDoubleItem* pDepthItem = nullptr;
+            const SfxUInt16Item* pMetricItem = nullptr;
             if( rReq.GetArgs() &&
-                (rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH ) == 
SfxItemState::SET) &&
-                (rReq.GetArgs()->GetItemState( SID_ATTR_METRIC ) == 
SfxItemState::SET))
+                (rReq.GetArgs()->GetItemState( SID_EXTRUSION_DEPTH, true, 
&pDepthItem ) == SfxItemState::SET) &&
+                (rReq.GetArgs()->GetItemState( SID_ATTR_METRIC, true, 
&pMetricItem ) == SfxItemState::SET))
             {
-                double fDepth = 
rReq.GetArgs()->GetItem<SvxDoubleItem>(SID_EXTRUSION_DEPTH)->GetValue();
-                FieldUnit eUnit = 
static_cast<FieldUnit>(rReq.GetArgs()->GetItem<SfxUInt16Item>(SID_ATTR_METRIC)->GetValue());
+                double fDepth = pDepthItem->GetValue();
+                FieldUnit eUnit = 
static_cast<FieldUnit>(pMetricItem->GetValue());
 
                 ExtrusionDepthDialog aDlg(rReq.GetFrameWeld(), fDepth, eUnit);
                 sal_uInt16 nRet = aDlg.run();
@@ -654,6 +663,7 @@ void ExtrusionBar::execute( SdrView* pSdrView, SfxRequest 
const & rReq, SfxBindi
                 }
             }
             break;
+        }
     }
 
     if( nSID != SID_EXTRUSION_TOGGLE )
diff --git a/svx/source/toolbars/fontworkbar.cxx 
b/svx/source/toolbars/fontworkbar.cxx
index ce629bab1405..f30b43d66250 100644
--- a/svx/source/toolbars/fontworkbar.cxx
+++ b/svx/source/toolbars/fontworkbar.cxx
@@ -255,9 +255,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
 
         case SID_FONTWORK_ALIGNMENT:
         {
-            if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_FONTWORK_ALIGNMENT ) == SfxItemState::SET )
+            const SfxInt32Item* pAlignItem = nullptr;
+            if( rReq.GetArgs() && rReq.GetArgs()->GetItemState( 
SID_FONTWORK_ALIGNMENT, true, &pAlignItem ) == SfxItemState::SET )
             {
-                sal_Int32 nValue = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_FONTWORK_ALIGNMENT)->GetValue();
+                sal_Int32 nValue = pAlignItem->GetValue();
                 if ( ( nValue >= 0 ) && ( nValue < 5 ) )
                 {
                     drawing::TextFitToSizeType eFTS = 
drawing::TextFitToSizeType_NONE;
@@ -280,9 +281,10 @@ static void impl_execute( SfxRequest const & rReq, 
SdrCustomShapeGeometryItem& r
 
         case SID_FONTWORK_CHARACTER_SPACING:
         {
-            if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( 
SID_FONTWORK_CHARACTER_SPACING ) == SfxItemState::SET ) )
+            const SfxInt32Item* pSpacingItem = nullptr;
+            if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( 
SID_FONTWORK_CHARACTER_SPACING, true, &pSpacingItem ) == SfxItemState::SET ) )
             {
-                sal_Int32 nCharSpacing = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_FONTWORK_CHARACTER_SPACING)->GetValue();
+                sal_Int32 nCharSpacing = pSpacingItem->GetValue();
                 pObj->SetMergedItem( SvxCharScaleWidthItem( 
static_cast<sal_uInt16>(nCharSpacing), EE_CHAR_FONTWIDTH ) );
                 pObj->BroadcastObjectChange();
             }
@@ -471,9 +473,10 @@ void FontworkBar::execute( SdrView& rSdrView, SfxRequest 
const & rReq, SfxBindin
 
         case SID_FONTWORK_CHARACTER_SPACING_DIALOG :
         {
-            if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( 
SID_FONTWORK_CHARACTER_SPACING ) == SfxItemState::SET ) )
+            const SfxInt32Item* pSpacingItem = nullptr;
+            if( rReq.GetArgs() && ( rReq.GetArgs()->GetItemState( 
SID_FONTWORK_CHARACTER_SPACING, true, &pSpacingItem ) == SfxItemState::SET ) )
             {
-                sal_Int32 nCharSpacing = 
rReq.GetArgs()->GetItem<SfxInt32Item>(SID_FONTWORK_CHARACTER_SPACING)->GetValue();
+                sal_Int32 nCharSpacing = pSpacingItem->GetValue();
                 FontworkCharacterSpacingDialog aDlg(rReq.GetFrameWeld(), 
nCharSpacing);
                 sal_uInt16 nRet = aDlg.run();
                 if (nRet != RET_CANCEL)
diff --git a/sw/source/core/crsr/viscrs.cxx b/sw/source/core/crsr/viscrs.cxx
index 64b9d3be49e1..c3f534d31b4b 100644
--- a/sw/source/core/crsr/viscrs.cxx
+++ b/sw/source/core/crsr/viscrs.cxx
@@ -333,10 +333,11 @@ std::optional<OString> SwVisibleCursor::getLOKPayload(int 
nType, int nViewId) co
                 SfxItemSetFixed<RES_TXTATR_INETFMT, RES_TXTATR_INETFMT>
                      aSet(m_pCursorShell->GetSfxViewShell()->GetPool());
                 pShell->GetCurAttr(aSet);
-                if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT 
))
+                const SwFormatINetFormat* pItem = nullptr;
+                if(SfxItemState::SET <= aSet.GetItemState( RES_TXTATR_INETFMT, 
true, &pItem ))
                 {
                     sHyperlink = 
buildHyperlinkJSON(m_pCursorShell->GetSelText(),
-                                                    
aSet.GetItem(RES_TXTATR_INETFMT)->GetValue());
+                                                    pItem->GetValue());
                 }
             }
         }
diff --git a/sw/source/core/text/txtfld.cxx b/sw/source/core/text/txtfld.cxx
index 43e4b9e906de..308b6cce3c91 100644
--- a/sw/source/core/text/txtfld.cxx
+++ b/sw/source/core/text/txtfld.cxx
@@ -350,14 +350,15 @@ static void 
checkApplyParagraphMarkFormatToNumbering(SwFont* pNumFnt, SwTextForm
         sal_uInt16 nWhich = aIter.FirstWhich();
         while (nWhich)
         {
+            const SfxPoolItem* pItem = nullptr;
             if (!SwTextNode::IsIgnoredCharFormatForNumbering(nWhich, 
/*bIsCharStyle=*/true)
                 && !pCleanedSet->HasItem(nWhich)
                 && !(pFormat && pFormat->HasItem(nWhich))
-                && rStyleAttrs.GetItemState(nWhich) > SfxItemState::DEFAULT)
+                && rStyleAttrs.GetItemState(nWhich, true, &pItem) > 
SfxItemState::DEFAULT)
             {
                 // Copy from parent sets only allowed items which will not 
overwrite
                 // values explicitly defined in current set (pCleanedSet) or 
in pFormat
-                if (const SfxPoolItem* pItem = rStyleAttrs.GetItem(nWhich, 
true))
+                if (pItem)
                     pCleanedSet->Put(*pItem);
             }
             nWhich = aIter.NextWhich();
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 3ad841ff5d43..94a46f7ab224 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -324,9 +324,9 @@ void MSWordExportBase::OutputItemSet( const SfxItemSet& 
rSet, bool bPapFormat, b
     if ( bPapFormat && SfxItemState::SET == rSet.GetItemState( RES_FRAMEDIR, 
bExportParentItemSet ) )
     {
         // No explicit adjust set ?
-        if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, 
bExportParentItemSet ) )
+        const SvxAdjustItem* pItem = nullptr;
+        if ( SfxItemState::SET != rSet.GetItemState( RES_PARATR_ADJUST, 
bExportParentItemSet, &pItem ) )
         {
-            const SvxAdjustItem* pItem = rSet.GetItem( RES_PARATR_ADJUST, 
bExportParentItemSet );
             if ( nullptr != pItem )
             {
                 // then set the adjust used by the parent format

Reply via email to