these can be stack allocated

Change-Id: I7be63816fcdc3572d751fdd9ceab5931d0559ffc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135124
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
diff --git a/sw/source/core/crsr/findattr.cxx b/sw/source/core/crsr/findattr.cxx
index 3f69528..ac53ea5 100644
--- a/sw/source/core/crsr/findattr.cxx
+++ b/sw/source/core/crsr/findattr.cxx
@@ -332,7 +332,7 @@ bool SwAttrCheckArr::SetAttrFwd( const SwTextAttr& rAttr )
    const SfxPoolItem* pItem;
    // here we explicitly also search in character templates
    sal_uInt16 nWhch = rAttr.Which();
    std::unique_ptr<SfxWhichIter> pIter;
    std::optional<SfxWhichIter> oIter;
    const SfxPoolItem* pTmpItem = nullptr;
    const SfxItemSet* pSet = nullptr;
    if( RES_TXTATR_CHARFMT == nWhch || RES_TXTATR_AUTOFMT == nWhch )
@@ -343,11 +343,11 @@ bool SwAttrCheckArr::SetAttrFwd( const SwTextAttr& rAttr )
        pSet = CharFormat::GetItemSet( rAttr.GetAttr() );
        if ( pSet )
        {
            pIter.reset(new SfxWhichIter( *pSet ));
            nWhch = pIter->FirstWhich();
            oIter.emplace( *pSet );
            nWhch = oIter->FirstWhich();
            while( nWhch &&
                SfxItemState::SET != pIter->GetItemState( true, &pTmpItem ) )
                nWhch = pIter->NextWhich();
                SfxItemState::SET != oIter->GetItemState( true, &pTmpItem ) )
                nWhch = oIter->NextWhich();
            if( !nWhch )
                pTmpItem = nullptr;
        }
@@ -462,20 +462,20 @@ bool SwAttrCheckArr::SetAttrFwd( const SwTextAttr& rAttr )
                }
            }
        }
        if( pIter )
        if( oIter )
        {
            assert(pSet && "otherwise no pIter");
            nWhch = pIter->NextWhich();
            assert(pSet && "otherwise no oIter");
            nWhch = oIter->NextWhich();
            while( nWhch &&
                SfxItemState::SET != pSet->GetItemState( nWhch, true, &pTmpItem ) )
                nWhch = pIter->NextWhich();
                nWhch = oIter->NextWhich();
            if( !nWhch )
                break;
        }
        else
            break;
    }
    pIter.reset();
    oIter.reset();
    return Found();
}

@@ -492,7 +492,7 @@ bool SwAttrCheckArr::SetAttrBwd( const SwTextAttr& rAttr )
    const SfxPoolItem* pItem;
    // here we explicitly also search in character templates
    sal_uInt16 nWhch = rAttr.Which();
    std::unique_ptr<SfxWhichIter> pIter;
    std::optional<SfxWhichIter> oIter;
    const SfxPoolItem* pTmpItem = nullptr;
    const SfxItemSet* pSet = nullptr;
    if( RES_TXTATR_CHARFMT == nWhch || RES_TXTATR_AUTOFMT == nWhch )
@@ -503,11 +503,11 @@ bool SwAttrCheckArr::SetAttrBwd( const SwTextAttr& rAttr )
        pSet = CharFormat::GetItemSet( rAttr.GetAttr() );
        if ( pSet )
        {
            pIter.reset( new SfxWhichIter( *pSet ) );
            nWhch = pIter->FirstWhich();
            oIter.emplace( *pSet );
            nWhch = oIter->FirstWhich();
            while( nWhch &&
                SfxItemState::SET != pIter->GetItemState( true, &pTmpItem ) )
                nWhch = pIter->NextWhich();
                SfxItemState::SET != oIter->GetItemState( true, &pTmpItem ) )
                nWhch = oIter->NextWhich();
            if( !nWhch )
                pTmpItem = nullptr;
        }
@@ -620,20 +620,20 @@ bool SwAttrCheckArr::SetAttrBwd( const SwTextAttr& rAttr )
                }
            }
        }
        if( pIter )
        if( oIter )
        {
            assert(pSet && "otherwise no pIter");
            nWhch = pIter->NextWhich();
            assert(pSet && "otherwise no oIter");
            nWhch = oIter->NextWhich();
            while( nWhch &&
                SfxItemState::SET != pSet->GetItemState( nWhch, true, &pTmpItem ) )
                nWhch = pIter->NextWhich();
                nWhch = oIter->NextWhich();
            if( !nWhch )
                break;
        }
        else
            break;
    }
    pIter.reset();
    oIter.reset();
    return Found();
}

diff --git a/sw/source/core/txtnode/thints.cxx b/sw/source/core/txtnode/thints.cxx
index 30c620d..0af7bc8 100644
--- a/sw/source/core/txtnode/thints.cxx
+++ b/sw/source/core/txtnode/thints.cxx
@@ -2209,7 +2209,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
                if( bChkInvalid )
                {
                    // ambiguous?
                    std::unique_ptr< SfxItemIter > pItemIter;
                    std::optional< SfxItemIter > oItemIter;
                    const SfxPoolItem* pItem = nullptr;

                    if ( RES_TXTATR_AUTOFMT == pHt->Which() )
@@ -2217,8 +2217,8 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,
                        const SfxItemSet* pAutoSet = CharFormat::GetItemSet( pHt->GetAttr() );
                        if ( pAutoSet )
                        {
                            pItemIter.reset( new SfxItemIter( *pAutoSet ) );
                            pItem = pItemIter->GetCurItem();
                            oItemIter.emplace( *pAutoSet );
                            pItem = oItemIter->GetCurItem();
                        }
                    }
                    else
@@ -2226,7 +2226,7 @@ bool SwTextNode::GetParaAttr(SfxItemSet& rSet, sal_Int32 nStt, sal_Int32 nEnd,

                    const sal_Int32 nHintEnd = *pAttrEnd;

                    for (; pItem; pItem = pItemIter ? pItemIter->NextItem() : nullptr)
                    for (; pItem; pItem = oItemIter ? oItemIter->NextItem() : nullptr)
                    {
                        const sal_uInt16 nHintWhich = pItem->Which();
                        OSL_ENSURE(!isUNKNOWNATR(nHintWhich),