cui/source/options/treeopt.cxx                |    6 
 include/sfx2/frame.hxx                        |    1 
 include/svl/itempool.hxx                      |    2 
 include/svl/itemset.hxx                       |   30 ++--
 include/svl/poolitem.hxx                      |    2 
 sc/source/core/data/patattr.cxx               |   24 +--
 sc/source/ui/drawfunc/drtxtob.cxx             |   10 -
 sc/source/ui/vba/vbarange.cxx                 |    2 
 sc/source/ui/view/formatsh.cxx                |   10 -
 sc/source/ui/view/output2.cxx                 |    6 
 sc/source/ui/view/spelleng.cxx                |    2 
 sd/source/ui/view/drviewsf.cxx                |   10 -
 sd/source/ui/view/outlnvsh.cxx                |    4 
 sfx2/source/control/dispatch.cxx              |   11 -
 sfx2/source/control/request.cxx               |    4 
 sfx2/source/doc/objserv.cxx                   |    2 
 sfx2/source/view/frame.cxx                    |   10 -
 svl/source/items/itemset.cxx                  |  157 +++++++++++++++++---------
 sw/source/core/attr/swatrset.cxx              |    8 -
 sw/source/core/doc/DocumentRedlineManager.cxx |    2 
 sw/source/filter/ww8/wrtw8nds.cxx             |    6 
 vbahelper/source/vbahelper/vbahelper.cxx      |   12 -
 22 files changed, 183 insertions(+), 138 deletions(-)

New commits:
commit b8e393686c4ab6a69b091240065f440eadfff230
Author:     Armin Le Grand (allotropia) <[email protected]>
AuthorDate: Mon Jan 15 18:45:03 2024 +0100
Commit:     Armin Le Grand <[email protected]>
CommitDate: Wed Jan 17 01:56:01 2024 +0100

    ITEM: Remove suspicious extra-Which in ::Put
    
    The ::Put methods at SfxItemSet had an extra WhichID
    parameter that was not really documented, but I would
    guess often asked why it exists: An extra WhichID, just
    called 'nWhich' (which makes things NOT clearer). That
    is 'strange' since the Item given to be put already
    internally has a WhichID, so why a 2nd one?
    
    If you were really interested and read all that code
    (no, no comments on that anywhere) you might know
    that this a kind of 'Target-WhichID' under which
    the Item shall be put to the ItemSet. Since this
    is unclear for most people it is even dangerous and
    explains why so many code places just hand over the
    WhichID requsted from the Item that already gets
    handed over.
    
    To make it short: I removed that. For the 19 places
    where this was really needed I added a new method
    besides ::Put called ::PutAsTargetWhich that takes that
    extra WhichID (now called TargetWhich) and takes the
    needed actions. These are quite some because that may
    be combined with the bPassingOwnership flag, see new
    SfxItemSet::PutImplAsTargetWhich method.
    
    This makes usage of ItemSets/Items less dangerous. It
    also simplifies and thus makes safer the central helpers
    implCreateItemEntry/implCleanupItemEntry which have some
    less cases to handle.
    
    Debugged the failing UnitTests showed that there is
    an incarnate Item != SfxVoidItem that causes problems.
    I checked for errors in the change, but no luck.
    Afterr some time I found out that a ::Clone
    implementation caused the problem: These need to
    also copy the WichID of the original, but the
    SfxFrameItem failed to do so. This did not cause
    problems in the former version because
    implCreateItemEntry was designed to set a missing/
    different WhichID.
    I corrected that in SfxFrameItem, also removed not
    needed costructor that caused that. Also added a
    SAL_WARN and a correction in implCreateItemEntry.
    I could have added an assert (did so for running
    local UnitTests), but should be enough.
    
    NOTE: When hunting for Items except SfxVoidItem
    that get crerated using a WhichID '0' i learned
    that this indeed happens: There are some (5) calls
    to SfxRequest::SetReturnValue that incarnate an
    SfxBoolItem with WhichID '0' (ZERO). This is not
    good and I think about how to change that...
    
    Change-Id: I9854a14cdc42d1cc19c7b9df65ce74147d680825
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162124
    Tested-by: Jenkins
    Reviewed-by: Armin Le Grand <[email protected]>

diff --git a/cui/source/options/treeopt.cxx b/cui/source/options/treeopt.cxx
index ef7eaa7dda0f..8bfbde910e10 100644
--- a/cui/source/options/treeopt.cxx
+++ b/cui/source/options/treeopt.cxx
@@ -1480,15 +1480,15 @@ std::optional<SfxItemSet> 
OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId )
 
                 SfxItemState aState(pDispatch->QueryState(SID_ATTR_LANGUAGE, 
aResult));
                 if(SfxItemState::DEFAULT <= aState)
-                    pRet->Put(*aResult.getItem(), SID_ATTR_LANGUAGE);
+                    pRet->Put(*aResult.getItem());
 
                 aState = pDispatch->QueryState(SID_ATTR_CHAR_CJK_LANGUAGE, 
aResult);
                 if(SfxItemState::DEFAULT <= aState)
-                    pRet->Put(*aResult.getItem(), SID_ATTR_CHAR_CJK_LANGUAGE);
+                    pRet->Put(*aResult.getItem());
 
                 aState = pDispatch->QueryState(SID_ATTR_CHAR_CTL_LANGUAGE, 
aResult);
                 if(SfxItemState::DEFAULT <= aState)
-                    pRet->Put(*aResult.getItem(), SID_ATTR_CHAR_CTL_LANGUAGE);
+                    pRet->Put(*aResult.getItem());
 
                 pRet->Put(aHyphen);
 
diff --git a/include/sfx2/frame.hxx b/include/sfx2/frame.hxx
index 888a1631f80e..b2b7159e9256 100644
--- a/include/sfx2/frame.hxx
+++ b/include/sfx2/frame.hxx
@@ -154,7 +154,6 @@ class SFX2_DLLPUBLIC SfxFrameItem final : public SfxPoolItem
 public:
 
                             SfxFrameItem( sal_uInt16 nWhich, SfxViewFrame 
const *p );
-                            SfxFrameItem( SfxFrame *p );
                             SfxFrameItem( sal_uInt16 nWhich, SfxFrame *p );
 
     virtual bool            operator==( const SfxPoolItem& ) const override;
diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx
index f6193bebe374..30a638d6609d 100644
--- a/include/svl/itempool.hxx
+++ b/include/svl/itempool.hxx
@@ -76,7 +76,7 @@ class SVL_DLLPUBLIC SfxItemPool : public 
salhelper::SimpleReferenceObject
     friend class SfxAllItemSet;
 
     // allow ItemSetTooling to access
-    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, sal_uInt16, bool);
+    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, bool);
     friend void implCleanupItemEntry(SfxPoolItem const*);
 
     // unit testing
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index b8b58828e2ac..6ccf86442159 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -39,7 +39,7 @@ SVL_DLLPUBLIC size_t getUsedSfxPoolItemHolderCount();
 #endif
 
 // ItemSet/ItemPool helpers
-SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* 
pSource, sal_uInt16 nWhich, bool bPassingOwnership);
+SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* 
pSource, bool bPassingOwnership);
 void implCleanupItemEntry(SfxPoolItem const* pSource);
 
 class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxPoolItemHolder
@@ -78,7 +78,7 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet
     friend class SfxWhichIter;
 
     // allow ItemSetTooling to access
-    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, sal_uInt16, bool);
+    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, bool);
     friend void implCleanupItemEntry(SfxPoolItem const*);
 
     SfxItemPool*      m_pPool;         ///< pool that stores the items
@@ -132,7 +132,8 @@ private:
     const SfxItemSet&           operator=(const SfxItemSet &) = delete;
 
 protected:
-    virtual const SfxPoolItem*  PutImpl( const SfxPoolItem&, sal_uInt16 
nWhich, bool bPassingOwnership );
+    virtual const SfxPoolItem*  PutImpl( const SfxPoolItem&, bool 
bPassingOwnership );
+    const SfxPoolItem* PutImplAsTargetWhich( const SfxPoolItem&, sal_uInt16 
nTargetWhich, bool bPassingOwnership );
 
     /** special constructor for SfxAllItemSet */
     enum class SfxAllItemSetFlag { Flag };
@@ -243,9 +244,10 @@ public:
     bool                        HasItem(TypedWhichId<T> nWhich, const T** 
ppItem = nullptr) const
     { return HasItem(sal_uInt16(nWhich), reinterpret_cast<const 
SfxPoolItem**>(ppItem)); }
 
-    void                        DisableItem(sal_uInt16 nWhich);
+    void DisableItem(sal_uInt16 nWhich)
+        { DisableItem_ForWhichID(nWhich); }
     void InvalidateItem(sal_uInt16 nWhich)
-    { InvalidateItem_ForWhichID(nWhich); }
+        { InvalidateItem_ForWhichID(nWhich); }
     sal_uInt16                  ClearItem( sal_uInt16 nWhich = 0);
     void                        ClearInvalidItems();
     void                        InvalidateAllItems(); // HACK(via nWhich = 0) 
???
@@ -254,14 +256,14 @@ public:
 
     // add, delete items, work on items
 public:
-    const SfxPoolItem*          Put( const SfxPoolItem& rItem, sal_uInt16 
nWhich )
-    { return PutImpl(rItem, nWhich, /*bPassingOwnership*/false); }
-    const SfxPoolItem*          Put( std::unique_ptr<SfxPoolItem> xItem, 
sal_uInt16 nWhich )
-    { return PutImpl(*xItem.release(), nWhich, /*bPassingOwnership*/true); }
     const SfxPoolItem*          Put( const SfxPoolItem& rItem )
-                                { return Put(rItem, rItem.Which()); }
+        { return PutImpl(rItem, /*bPassingOwnership*/false); }
     const SfxPoolItem*          Put( std::unique_ptr<SfxPoolItem> xItem )
-                                { auto nWhich = xItem->Which(); return 
Put(std::move(xItem), nWhich); }
+        { return PutImpl(*xItem.release(), /*bPassingOwnership*/true); }
+    const SfxPoolItem* PutAsTargetWhich(const SfxPoolItem& rItem, sal_uInt16 
nTargetWhich )
+        { return PutImplAsTargetWhich(rItem, nTargetWhich, false); }
+    const SfxPoolItem* PutAsTargetWhich(std::unique_ptr<SfxPoolItem> xItem, 
sal_uInt16 nTargetWhich )
+        { return PutImplAsTargetWhich(*xItem.release(), nTargetWhich, true); }
     bool                        Put( const SfxItemSet&,
                                      bool bInvalidAsDefault = true );
     void                        PutExtended( const SfxItemSet&,
@@ -311,9 +313,11 @@ private:
     // Merge two given Item(entries)
     void MergeItem_Impl(const SfxPoolItem **ppFnd1, const SfxPoolItem *pFnd2, 
bool bIgnoreDefaults);
 
-    // split version(s) of InvalidateItem for input types WhichID and Offset
+    // split version(s) of InvalidateItem/DisableItem for input types WhichID 
and Offset
     void InvalidateItem_ForWhichID(sal_uInt16 nWhich);
     void InvalidateItem_ForOffset(sal_uInt16 nOffset);
+    void DisableItem_ForWhichID(sal_uInt16 nWhich);
+    void DisableItem_ForOffset(sal_uInt16 nOffset);
 
     // split version(s) of GetItemStateImpl for input types WhichID and Offset
     SfxItemState GetItemState_ForWhichID( SfxItemState eState, sal_uInt16 
nWhich, bool bSrchInParent, const SfxPoolItem **ppItem) const;
@@ -337,7 +341,7 @@ public:
 
     virtual std::unique_ptr<SfxItemSet> Clone( bool bItems = true, SfxItemPool 
*pToPool = nullptr ) const override;
 private:
-    virtual const SfxPoolItem*  PutImpl( const SfxPoolItem&, sal_uInt16 
nWhich, bool bPassingOwnership ) override;
+    virtual const SfxPoolItem*  PutImpl( const SfxPoolItem&, bool 
bPassingOwnership ) override;
 };
 
 
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index e83cba61cc20..813e8c421cc4 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -114,7 +114,7 @@ class SVL_DLLPUBLIC SfxPoolItem
     friend class SfxItemSet;
 
     // allow ItemSetTooling to access
-    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, sal_uInt16, bool);
+    friend SfxPoolItem const* implCreateItemEntry(SfxItemPool&, SfxPoolItem 
const*, bool);
     friend void implCleanupItemEntry(SfxPoolItem const*);
 
     mutable sal_uInt32 m_nRefCount;
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 693e08b20e7a..bdfd5ad15801 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1078,13 +1078,13 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& r
     else
     {
         // tdf#125054 adapt WhichID
-        rEditSet.Put( std::move(aColorItem), EE_CHAR_COLOR );
+        rEditSet.PutAsTargetWhich( std::move(aColorItem), EE_CHAR_COLOR );
     }
 
     // tdf#125054 adapt WhichID
-    rEditSet.Put( std::move(aFontItem), EE_CHAR_FONTINFO );
-    rEditSet.Put( std::move(aCjkFontItem), EE_CHAR_FONTINFO_CJK );
-    rEditSet.Put( std::move(aCtlFontItem), EE_CHAR_FONTINFO_CTL );
+    rEditSet.PutAsTargetWhich( std::move(aFontItem), EE_CHAR_FONTINFO );
+    rEditSet.PutAsTargetWhich( std::move(aCjkFontItem), EE_CHAR_FONTINFO_CJK );
+    rEditSet.PutAsTargetWhich( std::move(aCtlFontItem), EE_CHAR_FONTINFO_CTL );
 
     rEditSet.Put( SvxFontHeightItem( nHeight, 100, EE_CHAR_FONTHEIGHT ) );
     rEditSet.Put( SvxFontHeightItem( nCjkHeight, 100, EE_CHAR_FONTHEIGHT_CJK ) 
);
@@ -1094,8 +1094,8 @@ void ScPatternAttr::FillToEditItemSet( SfxItemSet& 
rEditSet, const SfxItemSet& r
     rEditSet.Put( SvxWeightItem ( eCtlWeight,   EE_CHAR_WEIGHT_CTL ) );
 
     // tdf#125054 adapt WhichID
-    rEditSet.Put( std::move(aUnderlineItem), EE_CHAR_UNDERLINE );
-    rEditSet.Put( std::move(aOverlineItem), EE_CHAR_OVERLINE );
+    rEditSet.PutAsTargetWhich( std::move(aUnderlineItem), EE_CHAR_UNDERLINE );
+    rEditSet.PutAsTargetWhich( std::move(aOverlineItem), EE_CHAR_OVERLINE );
 
     rEditSet.Put( SvxWordLineModeItem( bWordLine,   EE_CHAR_WLM ) );
     rEditSet.Put( SvxCrossedOutItem( eStrike,       EE_CHAR_STRIKEOUT ) );
@@ -1130,14 +1130,14 @@ void ScPatternAttr::FillEditItemSet( SfxItemSet* 
pEditSet, const SfxItemSet* pCo
 void ScPatternAttr::GetFromEditItemSet( SfxItemSet& rDestSet, const 
SfxItemSet& rEditSet )
 {
     if (const SvxColorItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_COLOR))
-        rDestSet.Put( *pItem, ATTR_FONT_COLOR );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_FONT_COLOR );
 
     if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO))
-        rDestSet.Put( *pItem, ATTR_FONT );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_FONT );
     if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CJK))
-        rDestSet.Put( *pItem, ATTR_CJK_FONT );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_CJK_FONT );
     if (const SvxFontItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_FONTINFO_CTL))
-        rDestSet.Put( *pItem, ATTR_CTL_FONT );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_CTL_FONT );
 
     if (const SvxFontHeightItem* pItem = 
rEditSet.GetItemIfSet(EE_CHAR_FONTHEIGHT))
         rDestSet.Put( SvxFontHeightItem(o3tl::toTwips(pItem->GetHeight(), 
o3tl::Length::mm100),
@@ -1161,9 +1161,9 @@ void ScPatternAttr::GetFromEditItemSet( SfxItemSet& 
rDestSet, const SfxItemSet&
 
     // SvxTextLineItem contains enum and color
     if (const SvxUnderlineItem* pItem = 
rEditSet.GetItemIfSet(EE_CHAR_UNDERLINE))
-        rDestSet.Put( *pItem, ATTR_FONT_UNDERLINE );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_FONT_UNDERLINE );
     if (const SvxOverlineItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_OVERLINE))
-        rDestSet.Put( *pItem, ATTR_FONT_OVERLINE );
+        rDestSet.PutAsTargetWhich( *pItem, ATTR_FONT_OVERLINE );
     if (const SvxWordLineModeItem* pItem = rEditSet.GetItemIfSet(EE_CHAR_WLM))
         rDestSet.Put( SvxWordLineModeItem( pItem->GetValue(),
                         ATTR_FONT_WORDLINE) );
diff --git a/sc/source/ui/drawfunc/drtxtob.cxx 
b/sc/source/ui/drawfunc/drtxtob.cxx
index 189ae2793a10..a04f86a2f44d 100644
--- a/sc/source/ui/drawfunc/drtxtob.cxx
+++ b/sc/source/ui/drawfunc/drtxtob.cxx
@@ -241,14 +241,8 @@ void ScDrawTextObjectBar::Execute( SfxRequest &rReq )
                 if ( !aString.isEmpty() )
                 {
                     SfxItemSet aSet( pOutliner->GetEmptyItemSet() );
-                    // tdf#125054
-                    // checked against original, indeed aNewItem looks as if 
it can have
-                    // either WhichID EE_CHAR_FONTINFO or ATTR_FONT when it 
was reset
-                    // above, original uses '= SvxFontItem(..., ATTR_FONT).
-                    // BUT beware: the operator=() did not copy the WhichID 
when resetting,
-                    // so it indeed has WhichID of EE_CHAR_FONTINFO despite 
copying an Item
-                    // that was constructed using ATTR_FONT as WhichID (!)
-                    aSet.Put( *aNewItem, EE_CHAR_FONTINFO );
+                    // tdf#125054 set and force to needed WhichID
+                    aSet.PutAsTargetWhich( *aNewItem, EE_CHAR_FONTINFO );
 
                     //  If nothing is selected, then SetAttribs of the View 
selects a word
                     pOutView->GetOutliner()->QuickSetAttribs( aSet, 
pOutView->GetSelection() );
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 12d38b5e9b0b..fe38b2fc6dce 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -3652,7 +3652,7 @@ ScVbaRange::End( ::sal_Int32 Direction )
         // Hoping this will make sure this slot is called
         // synchronously
         SfxBoolItem sfxAsync( SID_ASYNCHRON, false );
-        aArgs.Put( sfxAsync, sfxAsync.Which() );
+        aArgs.Put( sfxAsync );
         SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
 
         sal_uInt16 nSID = 0;
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 9c231f1d4b5a..b426fae68722 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -744,7 +744,7 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
                         if( dynamic_cast<const SvxUnderlineItem*>( 
&rUnderline) !=  nullptr )
                         {
                             pTabViewShell->ApplyAttr( rUnderline );
-                            pNewSet->Put( rUnderline,rUnderline.Which() );
+                            pNewSet->Put( rUnderline );
                         }
                         else if ( auto pTextLineItem = dynamic_cast<const 
SvxTextLineItem*>( &rUnderline) )
                         {
@@ -752,7 +752,7 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
                             SvxUnderlineItem aNewItem( 
pTextLineItem->GetLineStyle(), pTextLineItem->Which() );
                             aNewItem.SetColor( pTextLineItem->GetColor() );
                             pTabViewShell->ApplyAttr( aNewItem );
-                            pNewSet->Put( aNewItem, aNewItem.Which() );
+                            pNewSet->Put( aNewItem );
                         }
                     }
                     else
@@ -763,7 +763,7 @@ void ScFormatShell::ExecuteTextAttr( SfxRequest& rReq )
                                     : LINESTYLE_SINGLE;
                         aUnderline.SetLineStyle( eUnderline );
                         pTabViewShell->ApplyAttr( aUnderline );
-                        pNewSet->Put( aUnderline,aUnderline.Which() );
+                        pNewSet->Put( aUnderline );
                     }
                 }
                 break;
@@ -971,7 +971,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
                     pTabViewShell->ApplyAttr( aBreakItem );
 
                     SfxAllItemSet aNewSet( GetPool() );
-                    aNewSet.Put( aBreakItem,aBreakItem.Which() );
+                    aNewSet.Put( aBreakItem );
                     rReq.Done( aNewSet );
 
                     rBindings.Invalidate( nSlot );
@@ -990,7 +990,7 @@ void ScFormatShell::ExecuteAttr( SfxRequest& rReq )
                     pTabViewShell->ApplyAttr( aProtectionItem );
 
                     SfxAllItemSet aNewSet( GetPool() );
-                    aNewSet.Put( aProtectionItem, aProtectionItem.Which());
+                    aNewSet.Put( aProtectionItem );
                     aNewSet.Put( SfxBoolItem( SID_SCATTR_CELLPROTECTION, 
!bProtect ) );
                     rReq.Done( aNewSet );
 
diff --git a/sc/source/ui/view/output2.cxx b/sc/source/ui/view/output2.cxx
index f9e4749377d7..73c7e13d9031 100644
--- a/sc/source/ui/view/output2.cxx
+++ b/sc/source/ui/view/output2.cxx
@@ -2555,17 +2555,17 @@ void 
ScOutputData::DrawEditParam::setPatternToEngine(bool bUseStyleColor)
         if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( 
ATTR_FONT ) )
         {
             // tdf#125054 adapt WhichID
-            pSet->Put(*pItem, EE_CHAR_FONTINFO);
+            pSet->PutAsTargetWhich(*pItem, EE_CHAR_FONTINFO);
         }
         if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( 
ATTR_CJK_FONT ) )
         {
             // tdf#125054 adapt WhichID
-            pSet->Put(*pItem, EE_CHAR_FONTINFO_CJK);
+            pSet->PutAsTargetWhich(*pItem, EE_CHAR_FONTINFO_CJK);
         }
         if ( const SvxFontItem* pItem = mpPreviewFontSet->GetItemIfSet( 
ATTR_CTL_FONT ) )
         {
             // tdf#125054 adapt WhichID
-            pSet->Put(*pItem, EE_CHAR_FONTINFO_CTL);
+            pSet->PutAsTargetWhich(*pItem, EE_CHAR_FONTINFO_CTL);
         }
     }
     bool bParaHyphenate = pSet->Get(EE_PARA_HYPHENATE).GetValue();
diff --git a/sc/source/ui/view/spelleng.cxx b/sc/source/ui/view/spelleng.cxx
index 0183e1e04f34..7fc859b616fa 100644
--- a/sc/source/ui/view/spelleng.cxx
+++ b/sc/source/ui/view/spelleng.cxx
@@ -143,7 +143,7 @@ bool ScConversionEngineBase::FindNextConversionCell()
                     else
                         pNewAttr = new 
ScPatternAttr(mrDoc.getCellAttributeHelper());
 
-                    pNewAttr->GetItemSet().Put(SvxLanguageItem(aLang.nLang, 
EE_CHAR_LANGUAGE), ATTR_FONT_LANGUAGE);
+                    pNewAttr->GetItemSet().Put(SvxLanguageItem(aLang.nLang, 
ATTR_FONT_LANGUAGE));
                     mrDoc.SetPattern(aPos, CellAttributeHolder(pNewAttr, 
true));
                 }
 
diff --git a/sd/source/ui/view/drviewsf.cxx b/sd/source/ui/view/drviewsf.cxx
index 1844d796036d..979225bb06dd 100644
--- a/sd/source/ui/view/drviewsf.cxx
+++ b/sd/source/ui/view/drviewsf.cxx
@@ -496,7 +496,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                     if( nSlotId != SID_STYLE_APPLY && 
!mpDrawView->AreObjectsMarked() )
                     {
                         SfxTemplateItem aTmpItem( nWhich, OUString() );
-                        aAllSet.Put( aTmpItem, aTmpItem.Which()  );
+                        aAllSet.Put( aTmpItem );
                     }
                     else
                     {
@@ -512,19 +512,19 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                                 (eFamily == SfxStyleFamily::Pseudo &&   
nSlotId == SID_STYLE_FAMILY5))
                             {
                                 SfxTemplateItem aTmpItem ( nWhich, 
pStyleSheet->GetName() );
-                                aAllSet.Put( aTmpItem, aTmpItem.Which()  );
+                                aAllSet.Put( aTmpItem );
                             }
                             else
                             {
                                 SfxTemplateItem aTmpItem(nWhich, OUString());
-                                aAllSet.Put(aTmpItem,aTmpItem.Which()  );
+                                aAllSet.Put( aTmpItem );
                             }
                         }
                     }
                 }
                 else
                 {   SfxTemplateItem aItem( nWhich, OUString() );
-                    aAllSet.Put( aItem, aItem.Which() );
+                    aAllSet.Put( aItem );
                 }
             }
             break;
@@ -555,7 +555,7 @@ void DrawViewShell::GetAttrState( SfxItemSet& rSet )
                 else
                 {
                     SfxBoolItem aItem(nWhich, SD_MOD()->GetWaterCan());
-                    aAllSet.Put( aItem, aItem.Which());
+                    aAllSet.Put( aItem );
                 }
             }
             break;
diff --git a/sd/source/ui/view/outlnvsh.cxx b/sd/source/ui/view/outlnvsh.cxx
index 718b28514e60..b234f8bca0e2 100644
--- a/sd/source/ui/view/outlnvsh.cxx
+++ b/sd/source/ui/view/outlnvsh.cxx
@@ -1448,14 +1448,14 @@ void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
                     if (pStyleSheet)
                     {
                         SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() 
);
-                        aAllSet.Put( aItem, aItem.Which()  );
+                        aAllSet.Put( aItem );
                     }
                 }
 
                 if( !pStyleSheet )
                 {
                     SfxTemplateItem aItem( nWhich, OUString() );
-                    aAllSet.Put( aItem, aItem.Which() );
+                    aAllSet.Put( aItem );
                     // rSet.DisableItem( nWhich );
                 }
             }
diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx
index 31540b89a3ea..a73fd763cd18 100644
--- a/sfx2/source/control/dispatch.cxx
+++ b/sfx2/source/control/dispatch.cxx
@@ -758,12 +758,11 @@ void SfxDispatcher::Execute_(SfxShell& rShell, const 
SfxSlot& rSlot,
 */
 static void MappedPut_Impl(SfxAllItemSet &rSet, const SfxPoolItem &rItem)
 {
-    // Put with mapped Which-Id if possible
-    const SfxItemPool *pPool = rSet.GetPool();
-    sal_uInt16 nWhich = rItem.Which();
-    if ( SfxItemPool::IsSlot(nWhich) )
-        nWhich = pPool->GetWhich(nWhich);
-    rSet.Put( rItem, nWhich );
+    // Put with mapped Which-Id if needed
+    if (SfxItemPool::IsSlot(rItem.Which()))
+        rSet.PutAsTargetWhich(rItem, rSet.GetPool()->GetWhich(rItem.Which()));
+    else
+        rSet.Put(rItem);
 }
 
 const SfxSlot* SfxDispatcher::GetSlot( const OUString& rCommand )
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index c44ebef2eb55..606399f208f2 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -402,7 +402,7 @@ void SfxRequest::AppendItem(const SfxPoolItem &rItem)
 {
     if(!pArgs)
         pArgs.reset( new SfxAllItemSet(*pImpl->pPool) );
-    pArgs->Put(rItem, rItem.Which());
+    pArgs->Put(rItem);
 }
 
 
@@ -474,7 +474,7 @@ void SfxRequest::Done
         for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = 
aIter.NextItem())
         {
             if(!IsInvalidItem(pItem))
-                pArgs->Put(*pItem,pItem->Which());
+                pArgs->Put(*pItem);
         }
     }
 }
diff --git a/sfx2/source/doc/objserv.cxx b/sfx2/source/doc/objserv.cxx
index 5de217fd6a6d..341919356588 100644
--- a/sfx2/source/doc/objserv.cxx
+++ b/sfx2/source/doc/objserv.cxx
@@ -1292,7 +1292,7 @@ void SfxObjectShell::ExecFile_Impl(SfxRequest &rReq)
                     }
                     SfxAllItemSet aArgs( GetPool() );
                     SfxStringItem aTmpItem( SID_FILE_NAME, 
pNameItem->GetValue() );
-                    aArgs.Put( aTmpItem, aTmpItem.Which() );
+                    aArgs.Put( aTmpItem );
                     SfxRequest aSaveAsReq( SID_SAVEASDOC, SfxCallMode::API, 
aArgs );
                     ExecFile_Impl( aSaveAsReq );
                     if ( !aSaveAsReq.IsDone() )
diff --git a/sfx2/source/view/frame.cxx b/sfx2/source/view/frame.cxx
index ad04da35343b..cfbdbaa706ff 100644
--- a/sfx2/source/view/frame.cxx
+++ b/sfx2/source/view/frame.cxx
@@ -389,12 +389,6 @@ SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxFrame 
*p ):
 {
 }
 
-SfxFrameItem::SfxFrameItem( SfxFrame *p ):
-    SfxPoolItem( 0 ),
-    pFrame( p ), wFrame( p )
-{
-}
-
 bool SfxFrameItem::operator==( const SfxPoolItem &rItem ) const
 {
      return SfxPoolItem::operator==(rItem) &&
@@ -404,7 +398,9 @@ bool SfxFrameItem::operator==( const SfxPoolItem &rItem ) 
const
 
 SfxFrameItem* SfxFrameItem::Clone( SfxItemPool *) const
 {
-    SfxFrameItem* pNew = new SfxFrameItem( wFrame);
+    // Every ::Clone implementation *needs* to also ensure that
+    // the WhichID gets set/copied at the created Item (!)
+    SfxFrameItem* pNew = new SfxFrameItem(Which(), wFrame);
     pNew->pFrame = pFrame;
     return pNew;
 }
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index c2ac95207f22..3b0ba11aef36 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -82,7 +82,7 @@ SfxPoolItemHolder::SfxPoolItemHolder(SfxItemPool& rPool, 
const SfxPoolItem* pIte
     nUsedSfxPoolItemHolderCount++;
 #endif
     if (nullptr != m_pItem)
-        m_pItem = implCreateItemEntry(getPool(), m_pItem, m_pItem->Which(), 
bPassingOwnership);
+        m_pItem = implCreateItemEntry(getPool(), m_pItem, bPassingOwnership);
     if (nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()))
         getPool().registerPoolItemHolder(*this);
 }
@@ -100,7 +100,7 @@ SfxPoolItemHolder::SfxPoolItemHolder(const 
SfxPoolItemHolder& rHolder)
     nUsedSfxPoolItemHolderCount++;
 #endif
     if (nullptr != m_pItem)
-        m_pItem = implCreateItemEntry(getPool(), m_pItem, m_pItem->Which(), 
false);
+        m_pItem = implCreateItemEntry(getPool(), m_pItem, false);
     if (nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()))
         getPool().registerPoolItemHolder(*this);
 }
@@ -136,7 +136,7 @@ const SfxPoolItemHolder& SfxPoolItemHolder::operator=(const 
SfxPoolItemHolder& r
     m_pItem = rHolder.m_pItem;
 
     if (nullptr != m_pItem)
-        m_pItem = implCreateItemEntry(getPool(), m_pItem, m_pItem->Which(), 
false);
+        m_pItem = implCreateItemEntry(getPool(), m_pItem, false);
     if (nullptr != m_pItem && 
getPool().NeedsSurrogateSupport(m_pItem->Which()))
         getPool().registerPoolItemHolder(*this);
 
@@ -244,7 +244,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rOther,
 
     for (const auto& rSource : rOther)
     {
-        *ppDst = implCreateItemEntry(*GetPool(), rSource, 0, false);
+        *ppDst = implCreateItemEntry(*GetPool(), rSource, false);
         ppDst++;
     }
 
@@ -271,7 +271,7 @@ SfxItemSet::SfxItemSet(SfxItemPool& pool, 
WhichRangesContainer wids)
     assert(svl::detail::validRanges2(m_pWhichRanges));
 }
 
-SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* 
pSource, sal_uInt16 nWhich, bool bPassingOwnership)
+SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, SfxPoolItem const* 
pSource, bool bPassingOwnership)
 {
     if (nullptr == pSource)
         // SfxItemState::UNKNOWN aka current default (nullptr)
@@ -304,8 +304,7 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, 
SfxPoolItem const* pS
     }
 
     // get correct target WhichID
-    if (0 == nWhich)
-        nWhich = pSource->Which();
+    sal_uInt16 nWhich(pSource->Which());
 
     if (SfxItemPool::IsSlot(nWhich))
     {
@@ -316,8 +315,14 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, 
SfxPoolItem const* pS
         if (!bPassingOwnership)
             pSource = pSource->Clone(rPool.GetMasterPool());
 
+        // ARGH! Found out that *some* ::Clone implementations fail to also 
clone the
+        // WhichID set at the original Item, e.g. SfxFrameItem. Corrected 
there, but
+        // there may be more cases, so add a SAL_WARN here and correct this
         if (pSource->Which() != nWhich)
+        {
+            SAL_WARN("svl.items", "ITEM: Clone of Item with class " << 
typeid(*pSource).name() << " did NOT copy/set WhichID (!)");
             const_cast<SfxPoolItem*>(pSource)->SetWhich(nWhich);
+        }
 
         pSource->AddRef();
         return pSource;
@@ -379,14 +384,6 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, 
SfxPoolItem const* pS
     // stack or else)
     while(pSource->GetRefCount() > 0)
     {
-        if (pSource->Which() != nWhich)
-            // If the target WhichID differs from the WhichID of a shared Item
-            // the item needs to be cloned. This happens, e.g. in
-            // ScPatternAttr::GetFromEditItemSet existing items with WhichIDs
-            // from EditEngine get set at a SetItem's ItemSet with different
-            // target ranges (e.g. look for ATTR_FONT_UNDERLINE)
-            break;
-
         if (!pSource->isShareable())
             // not shareable, done
             break;
@@ -418,10 +415,6 @@ SfxPoolItem const* implCreateItemEntry(SfxItemPool& rPool, 
SfxPoolItem const* pS
     if (!bPassingOwnership)
         pSource = pSource->Clone(pMasterPool);
 
-    // ensure WhichID @Item
-    if (pSource->Which() != nWhich)
-        const_cast<SfxPoolItem*>(pSource)->SetWhich(nWhich);
-
     // increase RefCnt 0->1
     pSource->AddRef();
 
@@ -499,7 +492,7 @@ SfxItemSet::SfxItemSet( const SfxItemSet& rASet )
 
     for (const auto& rSource : rASet)
     {
-        *ppDst = implCreateItemEntry(*GetPool(), rSource, 0, false);
+        *ppDst = implCreateItemEntry(*GetPool(), rSource, false);
         ppDst++;
     }
 
@@ -813,10 +806,38 @@ bool SfxItemSet::HasItem(sal_uInt16 nWhich, const 
SfxPoolItem** ppItem) const
     return bRet;
 }
 
-const SfxPoolItem* SfxItemSet::PutImpl(const SfxPoolItem& rItem, sal_uInt16 
nWhich, bool bPassingOwnership)
+const SfxPoolItem* SfxItemSet::PutImplAsTargetWhich(const SfxPoolItem& rItem, 
sal_uInt16 nTargetWhich, bool bPassingOwnership)
 {
-    bool bActionNeeded(0 != nWhich);
-    sal_uInt16 nOffset(INVALID_WHICHPAIR_OFFSET);
+    if (0 == nTargetWhich || nTargetWhich == rItem.Which())
+        // nTargetWhich not different or not given, use default
+        return PutImpl(rItem, bPassingOwnership);
+
+    if (bPassingOwnership && 0 == rItem.GetRefCount())
+    {
+        // we *can* use rItem when it's not pooled AKA has no RefCount
+        const_cast<SfxPoolItem&>(rItem).SetWhich(nTargetWhich);
+        return PutImpl(rItem, true);
+    }
+
+    // else we have to create a clone, set WhichID at it and
+    // delete rItem when bPassingOwnership was intended
+    SfxPoolItem* pClone(rItem.Clone(GetPool()));
+    pClone->SetWhich(nTargetWhich);
+    if (bPassingOwnership)
+        delete &rItem;
+    return PutImpl(*pClone, true);
+}
+
+const SfxPoolItem* SfxItemSet::PutImpl(const SfxPoolItem& rItem, bool 
bPassingOwnership)
+{
+    if (0 == rItem.Which())
+    {
+        // no action needed: this *should* be SfxVoidItem(0) the only Items
+        // with 0 == WhichID -> only to be used by SfxItemSet::DisableItem
+        if (bPassingOwnership)
+            delete &rItem;
+        return nullptr;
+    }
 
 #ifdef _WIN32
     // Win build *insists* for initialization, triggers warning C4701:
@@ -828,11 +849,8 @@ const SfxPoolItem* SfxItemSet::PutImpl(const SfxPoolItem& 
rItem, sal_uInt16 nWhi
     const_iterator aEntry;
 #endif
 
-    if (bActionNeeded)
-    {
-        nOffset = GetRanges().getOffsetFromWhich(nWhich);
-        bActionNeeded = (INVALID_WHICHPAIR_OFFSET != nOffset);
-    }
+    sal_uInt16 nOffset(GetRanges().getOffsetFromWhich(rItem.Which()));
+    bool bActionNeeded(INVALID_WHICHPAIR_OFFSET != nOffset);
 
     if (bActionNeeded)
     {
@@ -853,15 +871,12 @@ const SfxPoolItem* SfxItemSet::PutImpl(const SfxPoolItem& 
rItem, sal_uInt16 nWhi
     if (!bActionNeeded)
     {
         if (bPassingOwnership)
-        {
             delete &rItem;
-        }
-
         return nullptr;
     }
 
     // prepare new entry
-    SfxPoolItem const* pNew(implCreateItemEntry(*GetPool(), &rItem, nWhich, 
bPassingOwnership));
+    const SfxPoolItem* pNew(implCreateItemEntry(*GetPool(), &rItem, 
bPassingOwnership));
 
     // Notification-Callback
     if(m_aCallback)
@@ -913,7 +928,7 @@ bool SfxItemSet::Put(const SfxItemSet& rSource, bool 
bInvalidAsDefault)
                 }
                 else
                 {
-                    bRetval |= nullptr != PutImpl(**aSource, nWhich, false);
+                    bRetval |= nullptr != PutImpl(**aSource, false);
                 }
             }
 
@@ -965,7 +980,7 @@ void SfxItemSet::PutExtended
                     switch (eDontCareAs)
                     {
                         case SfxItemState::SET:
-                            PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), 
nWhich, false);
+                            PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), 
false);
                             break;
 
                         case SfxItemState::DEFAULT:
@@ -983,7 +998,7 @@ void SfxItemSet::PutExtended
                 else
                 {
                     // Item is set:
-                    PutImpl(**aSource, nWhich, false);
+                    PutImpl(**aSource, false);
                 }
             }
             else
@@ -992,7 +1007,7 @@ void SfxItemSet::PutExtended
                 switch (eDefaultAs)
                 {
                     case SfxItemState::SET:
-                        PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), 
nWhich, false);
+                        PutImpl(rSource.GetPool()->GetDefaultItem(nWhich), 
false);
                         break;
 
                     case SfxItemState::DEFAULT:
@@ -1195,7 +1210,7 @@ bool SfxItemSet::Set
             }
             const SfxPoolItem* pItem;
             if( SfxItemState::SET == aIter2.GetItemState( true, &pItem ) )
-                bRet |= nullptr != Put( *pItem, pItem->Which() );
+                bRet |= nullptr != Put( *pItem );
             nWhich1 = aIter1.NextWhich();
             nWhich2 = aIter2.NextWhich();
         }
@@ -1470,7 +1485,7 @@ void SfxItemSet::MergeItem_Impl(const SfxPoolItem 
**ppFnd1, const SfxPoolItem *p
 
         else if ( pFnd2 && bIgnoreDefaults )
             // Decision table: default, set, doesn't matter, sal_True
-            *ppFnd1 = implCreateItemEntry(*GetPool(), pFnd2, 0, false);
+            *ppFnd1 = implCreateItemEntry(*GetPool(), pFnd2, false);
             // *ppFnd1 = &GetPool()->Put( *pFnd2 );
 
         if ( *ppFnd1 )
@@ -1623,6 +1638,53 @@ void SfxItemSet::InvalidateItem_ForOffset(sal_uInt16 
nOffset)
     *aFoundOne = INVALID_POOL_ITEM;
 }
 
+void SfxItemSet::DisableItem_ForWhichID(sal_uInt16 nWhich)
+{
+    const sal_uInt16 nOffset(GetRanges().getOffsetFromWhich(nWhich));
+
+    if (INVALID_WHICHPAIR_OFFSET != nOffset)
+    {
+        DisableItem_ForOffset(nOffset);
+    }
+}
+
+void SfxItemSet::DisableItem_ForOffset(sal_uInt16 nOffset)
+{
+    // check and assert from invalid offset. The caller is responsible for
+    // ensuring a valid offset (see callers, all checked & safe)
+    assert(nOffset < TotalCount());
+    const_iterator aFoundOne(begin() + nOffset);
+
+    if (nullptr == *aFoundOne)
+    {
+        // entry goes from nullptr -> invalid
+        ++m_nCount;
+    }
+    else
+    {
+        // entry is set
+        if ((*aFoundOne)->isVoidItem() && 0 == (*aFoundOne)->Which())
+            // already invalid item, done
+            return;
+    }
+
+    // prepare new entry
+    const SfxPoolItem* pNew(implCreateItemEntry(*GetPool(), new 
SfxVoidItem(0), true));
+
+    // Notification-Callback
+    if(m_aCallback)
+    {
+        m_aCallback(*aFoundOne, pNew);
+    }
+
+    // cleanup entry (remove only)
+    checkRemovePoolRegistration(*aFoundOne);
+    implCleanupItemEntry(*aFoundOne);
+
+    // set new entry
+    *aFoundOne = pNew;
+}
+
 sal_uInt16 SfxItemSet::GetWhichByOffset( sal_uInt16 nOffset ) const
 {
     assert(nOffset < TotalCount());
@@ -1746,7 +1808,7 @@ std::unique_ptr<SfxItemSet> SfxItemSet::Clone(bool 
bItems, SfxItemPool *pToPool
             {
                 const SfxPoolItem* pItem;
                 if ( SfxItemState::SET == 
GetItemState_ForWhichID(SfxItemState::UNKNOWN, nWhich, false, &pItem ) )
-                    pNewSet->Put( *pItem, pItem->Which() );
+                    pNewSet->Put( *pItem );
                 nWhich = aIter.NextWhich();
             }
         }
@@ -1775,7 +1837,7 @@ SfxItemSet SfxItemSet::CloneAsValue(bool bItems, 
SfxItemPool *pToPool ) const
             {
                 const SfxPoolItem* pItem;
                 if ( SfxItemState::SET == 
GetItemState_ForWhichID(SfxItemState::UNKNOWN, nWhich, false, &pItem ) )
-                    aNewSet.Put( *pItem, pItem->Which() );
+                    aNewSet.Put( *pItem );
                 nWhich = aIter.NextWhich();
             }
         }
@@ -1831,19 +1893,10 @@ SfxAllItemSet::SfxAllItemSet(const SfxAllItemSet &rCopy)
 /**
  * Putting with automatic extension of the WhichId with the ID of the Item.
  */
-const SfxPoolItem* SfxAllItemSet::PutImpl( const SfxPoolItem& rItem, 
sal_uInt16 nWhich, bool bPassingOwnership )
-{
-    MergeRange(nWhich, nWhich);
-    return SfxItemSet::PutImpl(rItem, nWhich, bPassingOwnership);
-}
-
-/**
- * Disable Item
- * Using a VoidItem with Which value 0
- */
-void SfxItemSet::DisableItem(sal_uInt16 nWhich)
+const SfxPoolItem* SfxAllItemSet::PutImpl( const SfxPoolItem& rItem, bool 
bPassingOwnership )
 {
-    Put( SfxVoidItem(0), nWhich );
+    MergeRange(rItem.Which(), rItem.Which());
+    return SfxItemSet::PutImpl(rItem, bPassingOwnership);
 }
 
 std::unique_ptr<SfxItemSet> SfxAllItemSet::Clone(bool bItems, SfxItemPool 
*pToPool ) const
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index c0155317c76e..09c04b43f635 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -141,12 +141,12 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, 
const SfxPoolItem* pNew)
             const SfxItemSet* pParent(GetParent());
             m_pOldSet->PutImpl(nullptr != pParent
                 ? pParent->Get(nWhich)
-                : GetPool()->GetDefaultItem(nWhich), nWhich, false);
+                : GetPool()->GetDefaultItem(nWhich), false);
         }
         else if (!IsInvalidItem(pOld))
         {
             // set/remember old value
-            m_pOldSet->PutImpl(*pOld, nWhich, false);
+            m_pOldSet->PutImpl(*pOld, false);
         }
     }
 
@@ -159,12 +159,12 @@ void SwAttrSet::changeCallback(const SfxPoolItem* pOld, 
const SfxPoolItem* pNew)
             const SfxItemSet* pParent(GetParent());
             m_pNewSet->PutImpl(nullptr != pParent
                 ? pParent->Get(nWhich)
-                : GetPool()->GetDefaultItem(nWhich), nWhich, false);
+                : GetPool()->GetDefaultItem(nWhich), false);
         }
         else if (!IsInvalidItem(pNew))
         {
             // set/remember new value
-            m_pNewSet->PutImpl(*pNew, nWhich, false);
+            m_pNewSet->PutImpl(*pNew, false);
         }
     }
 }
diff --git a/sw/source/core/doc/DocumentRedlineManager.cxx 
b/sw/source/core/doc/DocumentRedlineManager.cxx
index 8d52c814e81a..ab0fd4ef0de7 100644
--- a/sw/source/core/doc/DocumentRedlineManager.cxx
+++ b/sw/source/core/doc/DocumentRedlineManager.cxx
@@ -439,7 +439,7 @@ namespace
                     sal_uInt16 nWhich = aTmp.GetWhichByOffset(nItem);
                     if( SfxItemState::SET == aTmp.GetItemState( nWhich, false 
) &&
                         SfxItemState::SET != aTmp2.GetItemState( nWhich, false 
) )
-                            aTmp2.Put( aTmp.GetPool()->GetDefaultItem(nWhich), 
nWhich );
+                            aTmp2.Put( aTmp.GetPool()->GetDefaultItem(nWhich) 
);
                 }
             }
 
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx 
b/sw/source/filter/ww8/wrtw8nds.cxx
index 39e2f885230b..65dbf5b5beb3 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -658,7 +658,7 @@ void SwWW8AttrIter::handleToggleProperty(SfxItemSet& 
rExportSet, const SwFormatC
             if (hasWeightComplexPropertyInCharStyle && (pItem = 
pFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_WEIGHT)) &&
                 *pItem == aBoldProperty)
             {
-                rExportSet.Put(aBoldProperty, RES_CHRATR_CTL_WEIGHT);
+                rExportSet.PutAsTargetWhich(aBoldProperty, 
RES_CHRATR_CTL_WEIGHT);
             }
 
             if (hasPosturePropertyInCharStyle && (pItem = 
pFormat->GetAttrSet().GetItem(RES_CHRATR_POSTURE)) &&
@@ -668,7 +668,7 @@ void SwWW8AttrIter::handleToggleProperty(SfxItemSet& 
rExportSet, const SwFormatC
             if (hasPostureComplexPropertyInCharStyle && (pItem = 
pFormat->GetAttrSet().GetItem(RES_CHRATR_CTL_POSTURE)) &&
                 *pItem == aPostureProperty)
             {
-                rExportSet.Put(aPostureProperty, RES_CHRATR_CTL_POSTURE);
+                rExportSet.PutAsTargetWhich(aPostureProperty, 
RES_CHRATR_CTL_POSTURE);
             }
 
             if (hasContouredPropertyInCharStyle && (pItem = 
pFormat->GetAttrSet().GetItem(RES_CHRATR_CONTOUR)) && *pItem == 
aContouredProperty)
@@ -3104,7 +3104,7 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode )
 
                 const SvxAdjustItem* pAdjust = 
rNode.GetSwAttrSet().GetItem(RES_PARATR_ADJUST);
                 if ( pAdjust && (pAdjust->GetAdjust() == SvxAdjust::Left || 
pAdjust->GetAdjust() == SvxAdjust::Right ) )
-                    oTmpSet->Put( *pAdjust, RES_PARATR_ADJUST );
+                    oTmpSet->Put( *pAdjust );
             }
             // move code for handling of numbered,
             // but not counted paragraphs to this place. Otherwise, the 
paragraph
diff --git a/vbahelper/source/vbahelper/vbahelper.cxx 
b/vbahelper/source/vbahelper/vbahelper.cxx
index db4949e5f270..b367916748da 100644
--- a/vbahelper/source/vbahelper/vbahelper.cxx
+++ b/vbahelper/source/vbahelper/vbahelper.cxx
@@ -373,24 +373,24 @@ void PrintOutHelper( SfxViewShell const * pViewShell, 
const uno::Any& From, cons
     SfxAllItemSet aArgs( SfxGetpApp()->GetPool() );
 
     SfxBoolItem sfxCollate( SID_PRINT_COLLATE, bCollate );
-    aArgs.Put( sfxCollate, sfxCollate.Which() );
+    aArgs.Put( sfxCollate );
     SfxInt16Item sfxCopies( SID_PRINT_COPIES, nCopies );
-    aArgs.Put( sfxCopies, sfxCopies.Which() );
+    aArgs.Put( sfxCopies );
     if ( !sFileName.isEmpty() )
     {
         SfxStringItem sfxFileName( SID_FILE_NAME, sFileName);
-        aArgs.Put( sfxFileName, sfxFileName.Which() );
+        aArgs.Put( sfxFileName );
 
     }
     if (  !sRange.isEmpty() )
     {
         SfxStringItem sfxRange( SID_PRINT_PAGES, sRange );
-        aArgs.Put( sfxRange, sfxRange.Which() );
+        aArgs.Put( sfxRange );
     }
     SfxBoolItem sfxSelection( SID_SELECTION, bSelection );
-    aArgs.Put( sfxSelection, sfxSelection.Which() );
+    aArgs.Put( sfxSelection );
     SfxBoolItem sfxAsync( SID_ASYNCHRON, false );
-    aArgs.Put( sfxAsync, sfxAsync.Which() );
+    aArgs.Put( sfxAsync );
     SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher();
 
     if ( !pDispatcher )

Reply via email to