[Libreoffice-commits] core.git: chart2/source cui/source editeng/source extensions/source filter/source include/svl reportdesign/source sc/source sd/source svl/source svx/source sw/source

Noel Grandin noelgrandin at gmail.com
Fri May 27 07:22:19 UTC 2016


 chart2/source/controller/itemsetwrapper/ItemConverter.cxx |    3 
 cui/source/dialogs/cuihyperdlg.cxx                        |    4 
 cui/source/dialogs/hltpbase.cxx                           |    4 
 cui/source/options/connpooloptions.cxx                    |    4 
 cui/source/options/dbregister.cxx                         |    2 
 cui/source/tabpages/numpages.cxx                          |   12 -
 cui/source/tabpages/tparea.cxx                            |    3 
 cui/source/tabpages/tphatch.cxx                           |    6 
 editeng/source/editeng/editdoc.cxx                        |    9 -
 editeng/source/editeng/editview.cxx                       |    9 -
 editeng/source/outliner/outlvw.cxx                        |    4 
 editeng/source/uno/unoipset.cxx                           |    3 
 extensions/source/propctrlr/fontdialog.cxx                |   22 +-
 filter/source/msfilter/svdfppt.cxx                        |    4 
 include/svl/itemset.hxx                                   |    2 
 include/svl/poolitem.hxx                                  |    9 -
 reportdesign/source/ui/misc/UITools.cxx                   |    3 
 sc/source/core/data/stlpool.cxx                           |   12 -
 sc/source/core/data/stlsheet.cxx                          |    8 
 sc/source/core/tool/autoform.cxx                          |   24 ++
 sc/source/filter/excel/xlroot.cxx                         |    9 -
 sc/source/filter/ftools/ftools.cxx                        |    5 
 sc/source/filter/rtf/eeimpars.cxx                         |   28 ++-
 sc/source/filter/starcalc/scflt.cxx                       |   16 -
 sc/source/ui/Accessibility/AccessibleText.cxx             |    9 -
 sc/source/ui/app/inputwin.cxx                             |   35 ++--
 sc/source/ui/dbgui/csvgrid.cxx                            |   21 +-
 sc/source/ui/drawfunc/drawsh.cxx                          |    4 
 sc/source/ui/pagedlg/tphfedit.cxx                         |    9 -
 sc/source/ui/unoobj/textuno.cxx                           |    9 -
 sc/source/ui/view/formatsh.cxx                            |    3 
 sc/source/ui/view/printfun.cxx                            |    9 -
 sc/source/ui/view/viewutil.cxx                            |    5 
 sd/source/ui/dlg/dlgolbul.cxx                             |    3 
 sd/source/ui/func/fubullet.cxx                            |    6 
 sd/source/ui/func/fuolbull.cxx                            |    5 
 sd/source/ui/view/drtxtob.cxx                             |    6 
 sd/source/ui/view/drviews9.cxx                            |  118 +++++++++-----
 sd/source/ui/view/viewshel.cxx                            |    3 
 svl/source/items/itemprop.cxx                             |    2 
 svl/source/items/poolitem.cxx                             |    9 +
 svx/source/dialog/imapwnd.cxx                             |    2 
 svx/source/unodraw/UnoNameItemTable.cxx                   |    3 
 svx/source/unodraw/unomtabl.cxx                           |   16 -
 sw/source/core/attr/swatrset.cxx                          |    2 
 sw/source/core/doc/poolfmt.cxx                            |   10 -
 sw/source/core/doc/tblafmt.cxx                            |   18 +-
 sw/source/filter/ascii/parasc.cxx                         |   12 -
 sw/source/filter/ww8/ww8graf.cxx                          |    2 
 sw/source/ui/dbui/dbinsdlg.cxx                            |    6 
 sw/source/ui/frmdlg/wrap.cxx                              |    4 
 sw/source/uibase/app/appopt.cxx                           |   15 +
 sw/source/uibase/lingu/olmenu.cxx                         |    2 
 sw/source/uibase/shells/annotsh.cxx                       |   41 +++-
 sw/source/uibase/shells/basesh.cxx                        |   10 -
 sw/source/uibase/shells/drwtxtex.cxx                      |   19 +-
 sw/source/uibase/shells/drwtxtsh.cxx                      |   12 +
 sw/source/uibase/shells/langhelper.cxx                    |    2 
 sw/source/uibase/shells/tabsh.cxx                         |   13 +
 sw/source/uibase/shells/textsh.cxx                        |    9 -
 sw/source/uibase/shells/textsh1.cxx                       |    5 
 sw/source/uibase/uiview/formatclipboard.cxx               |   13 +
 sw/source/uibase/uiview/viewstat.cxx                      |   24 ++
 sw/source/uibase/uiview/viewtab.cxx                       |   18 +-
 64 files changed, 483 insertions(+), 236 deletions(-)

New commits:
commit 9eb2e683ab051edd0bce18841f0ac05df5038854
Author: Noel Grandin <noelgrandin at gmail.com>
Date:   Sat Apr 23 20:23:29 2016 +0200

    tdf#34465 remove calls to SfxItemSet::Put(const SfxPoolItem&, sal_uInt16)
    
    and put an assert in SfxPoolItem::SetWhich() so nothing new
    creeps in.
    
    Change-Id: I6497650fa61ffb2b6941ffff2d471c8f117be1df
    Reviewed-on: https://gerrit.libreoffice.org/24324
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noelgrandin at gmail.com>

diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
index 312eaea..20746e7 100644
--- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
+++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx
@@ -114,7 +114,8 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
                         }
                         else
                         {
-                            rOutItemSet.Put( *pItem, nWhich );
+                            pItem->SetWhich(nWhich);
+                            rOutItemSet.Put( *pItem );
                             delete pItem;
                         }
                     }
diff --git a/cui/source/dialogs/cuihyperdlg.cxx b/cui/source/dialogs/cuihyperdlg.cxx
index f0039c9..262cde9 100644
--- a/cui/source/dialogs/cuihyperdlg.cxx
+++ b/cui/source/dialogs/cuihyperdlg.cxx
@@ -117,8 +117,8 @@ SvxHpLinkDlg::SvxHpLinkDlg (vcl::Window* pParent, SfxBindings* pBindings)
     mpItemSet = new SfxItemSet( SfxGetpApp()->GetPool(), SID_HYPERLINK_GETLINK,
                                SID_HYPERLINK_SETLINK );
 
-    SvxHyperlinkItem aItem;
-    mpItemSet->Put (aItem, SID_HYPERLINK_GETLINK);
+    SvxHyperlinkItem aItem(SID_HYPERLINK_GETLINK);
+    mpItemSet->Put(aItem);
 
     SetInputSet (mpItemSet);
 
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index cef6aec..84f0c50 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -348,7 +348,7 @@ IMPL_LINK_NOARG_TYPED(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, voi
     {
         // get macros from itemset
         const SvxMacroTableDtor* pMacroTbl = pHyperlinkItem->GetMacroTable();
-        SvxMacroItem aItem ( GetWhich(SID_ATTR_MACROITEM) );
+        SvxMacroItem aItem ( SID_ATTR_MACROITEM );
         if( pMacroTbl )
             aItem.SetMacroTable( *pMacroTbl );
 
@@ -356,7 +356,7 @@ IMPL_LINK_NOARG_TYPED(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, voi
         SfxItemSet* pItemSet = new SfxItemSet(SfxGetpApp()->GetPool(),
                                               SID_ATTR_MACROITEM,
                                               SID_ATTR_MACROITEM );
-        pItemSet->Put ( aItem, SID_ATTR_MACROITEM );
+        pItemSet->Put ( aItem );
 
         /*  disable HyperLinkDlg for input while the MacroAssignDlg is working
             because if no JAVA is installed an error box occurs and then it is possible
diff --git a/cui/source/options/connpooloptions.cxx b/cui/source/options/connpooloptions.cxx
index 9af9aec7..0cd9fb2 100644
--- a/cui/source/options/connpooloptions.cxx
+++ b/cui/source/options/connpooloptions.cxx
@@ -381,14 +381,14 @@ namespace offapp
         // the enabled flag
         if (m_pEnablePooling->IsValueChangedFromSaved())
         {
-            _rSet->Put(SfxBoolItem(SID_SB_POOLING_ENABLED, m_pEnablePooling->IsChecked()), SID_SB_POOLING_ENABLED);
+            _rSet->Put(SfxBoolItem(SID_SB_POOLING_ENABLED, m_pEnablePooling->IsChecked()));
             bModified = true;
         }
 
         // the settings for the single drivers
         if (m_pDriverList->isModified())
         {
-            _rSet->Put(DriverPoolingSettingsItem(SID_SB_DRIVER_TIMEOUTS, m_pDriverList->getSettings()), SID_SB_DRIVER_TIMEOUTS);
+            _rSet->Put(DriverPoolingSettingsItem(SID_SB_DRIVER_TIMEOUTS, m_pDriverList->getSettings()));
             bModified = true;
         }
 
diff --git a/cui/source/options/dbregister.cxx b/cui/source/options/dbregister.cxx
index f0d1651..c3a422c 100644
--- a/cui/source/options/dbregister.cxx
+++ b/cui/source/options/dbregister.cxx
@@ -204,7 +204,7 @@ bool DbRegistrationOptionsPage::FillItemSet( SfxItemSet* rCoreSet )
     }
     if ( m_nOldCount != aRegistrations.size() || m_bModified )
     {
-        rCoreSet->Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ), SID_SB_DB_REGISTER);
+        rCoreSet->Put(DatabaseMapItem( SID_SB_DB_REGISTER, aRegistrations ));
         bModified = true;
     }
 
diff --git a/cui/source/tabpages/numpages.cxx b/cui/source/tabpages/numpages.cxx
index 22d23e0..d4a7ad4 100644
--- a/cui/source/tabpages/numpages.cxx
+++ b/cui/source/tabpages/numpages.cxx
@@ -250,7 +250,7 @@ bool  SvxSingleNumPickTabPage::FillItemSet( SfxItemSet* rSet )
     if( (bPreset || bModified) && pSaveNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     }
 
@@ -416,7 +416,7 @@ bool  SvxBulletPickTabPage::FillItemSet( SfxItemSet* rSet )
     if( (bPreset || bModified) && pActNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     }
     return bModified;
@@ -618,7 +618,7 @@ bool  SvxNumPickTabPage::FillItemSet( SfxItemSet* rSet )
     if( (bPreset || bModified) && pActNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     }
     return bModified;
@@ -916,7 +916,7 @@ bool  SvxBitmapPickTabPage::FillItemSet( SfxItemSet* rSet )
     if( (bPreset || bModified) && pActNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ) );
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, bPreset));
     }
 
@@ -1375,7 +1375,7 @@ bool    SvxNumOptionsTabPage::FillItemSet( SfxItemSet* rSet )
     if(bModified && pActNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
     }
     return bModified;
@@ -3153,7 +3153,7 @@ bool SvxNumPositionTabPage::FillItemSet( SfxItemSet* rSet )
     if(bModified && pActNum)
     {
         *pSaveNum = *pActNum;
-        rSet->Put(SvxNumBulletItem( *pSaveNum ), nNumItemId);
+        rSet->Put(SvxNumBulletItem( *pSaveNum, nNumItemId ));
         rSet->Put(SfxBoolItem(SID_PARAM_NUM_PRESET, false));
     }
     return bModified;
diff --git a/cui/source/tabpages/tparea.cxx b/cui/source/tabpages/tparea.cxx
index 29b3470..431e106 100644
--- a/cui/source/tabpages/tparea.cxx
+++ b/cui/source/tabpages/tparea.cxx
@@ -1348,7 +1348,8 @@ IMPL_LINK_NOARG_TYPED(SvxAreaTabPage, ModifyHatchingHdl_Impl, ListBox&, void)
 
     // fill Hatch background ItemSet
     XFillBackgroundItem aItem(static_cast<const XFillBackgroundItem&>(m_rOutAttrs.Get( XATTR_FILLBACKGROUND )));
-    m_rXFSet.Put( aItem, XATTR_FILLBACKGROUND );
+    aItem.SetWhich( XATTR_FILLBACKGROUND );
+    m_rXFSet.Put ( aItem );
     if(aItem.GetValue())
     {
         if( SfxItemState::SET == m_rOutAttrs.GetItemState( GetWhich( XATTR_FILLCOLOR ), true, &pPoolItem ) )
diff --git a/cui/source/tabpages/tphatch.cxx b/cui/source/tabpages/tphatch.cxx
index ac5af61..78e5fa8 100644
--- a/cui/source/tabpages/tphatch.cxx
+++ b/cui/source/tabpages/tphatch.cxx
@@ -338,7 +338,8 @@ bool SvxHatchTabPage::FillItemSet( SfxItemSet* rSet )
 
             sal_uInt32 nPosBckColor = m_pLbBackgroundColor->GetSelectEntryPos();
             XFillBackgroundItem aItem( m_pLbBackgroundColor->GetSelectEntryColor() != COL_WHITE );
-            rSet->Put( aItem , XATTR_FILLBACKGROUND );
+            aItem.SetWhich( XATTR_FILLBACKGROUND );
+            rSet->Put( aItem );
             if(aItem.GetValue())
             {
                 OUString aBckColorString;
@@ -418,7 +419,8 @@ void SvxHatchTabPage::ModifiedHdl_Impl( void* p )
     m_rXFSet.Put( XFillHatchItem( OUString(), aXHatch ) );
 
     XFillBackgroundItem aItem( m_pLbBackgroundColor->GetSelectEntryColor() != COL_WHITE );
-    m_rXFSet.Put( aItem, XATTR_FILLBACKGROUND );
+    aItem.SetWhich( XATTR_FILLBACKGROUND );
+    m_rXFSet.Put( aItem );
     if(aItem.GetValue())
         m_rXFSet.Put( XFillColorItem( OUString(), m_pLbBackgroundColor->GetSelectEntryColor() ) );
     m_pCtlPreview->SetAttributes( m_aXFillAttr.GetItemSet() );
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index c7b2027..78fa1f0 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -949,14 +949,15 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map
             if ( eSourceUnit != eDestUnit )
             {
                 SfxPoolItem* pItem = rSource.Get( nSourceWhich ).Clone();
-//              pItem->SetWhich( nWhich );
                 ConvertItem( *pItem, eSourceUnit, eDestUnit );
-                rDest.Put( *pItem, nWhich );
+                pItem->SetWhich(nWhich);
+                rDest.Put( *pItem );
                 delete pItem;
             }
             else
             {
-                rDest.Put( rSource.Get( nSourceWhich ), nWhich );
+                std::unique_ptr<SfxPoolItem> pNewItem(rSource.Get( nSourceWhich ).CloneSetWhich(nWhich));
+                rDest.Put( *pNewItem );
             }
         }
     }
@@ -2322,7 +2323,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs )
     ContentAttribs aContentAttribs( aPaM.GetNode()->GetContentAttribs() );
 
     // for a new paragraph we like to have the bullet/numbering visible by default
-    aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true), EE_PARA_BULLETSTATE );
+    aContentAttribs.GetItems().Put( SfxBoolItem( EE_PARA_BULLETSTATE, true) );
 
     // ContentNode constructor copies also the paragraph attributes
     ContentNode* pNode = new ContentNode( aStr, aContentAttribs );
diff --git a/editeng/source/editeng/editview.cxx b/editeng/source/editeng/editview.cxx
index 3c0852e..e9a36bf 100644
--- a/editeng/source/editeng/editview.cxx
+++ b/editeng/source/editeng/editview.cxx
@@ -1121,9 +1121,9 @@ static void ChangeFontSizeImpl( EditView* pEditView, bool bGrow, const ESelectio
     if( EditView::ChangeFontSize( bGrow, aSet, pFontList ) )
     {
         SfxItemSet aNewSet( pEditView->GetEmptyItemSet() );
-        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT ), EE_CHAR_FONTHEIGHT );
-        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CJK ), EE_CHAR_FONTHEIGHT_CJK );
-        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CTL ), EE_CHAR_FONTHEIGHT_CTL );
+        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT ) );
+        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CJK ) );
+        aNewSet.Put( aSet.Get( EE_CHAR_FONTHEIGHT_CTL ) );
         pEditView->SetAttribs( aNewSet );
     }
 }
@@ -1258,7 +1258,8 @@ bool EditView::ChangeFontSize( bool bGrow, SfxItemSet& rSet, const FontList* pFo
             if( nHeight != (long)aFontHeightItem.GetHeight() )
             {
                 aFontHeightItem.SetHeight( nHeight );
-                rSet.Put( aFontHeightItem, *pWhich );
+                std::unique_ptr<SfxPoolItem> pNewItem(aFontHeightItem.CloneSetWhich(*pWhich));
+                rSet.Put( *pNewItem );
                 bRet = true;
             }
         }
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 5f5a8d1..a64d85b 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -881,7 +881,7 @@ void OutlinerView::ToggleBullets()
                     {
                         SfxItemSet aAttrs( pOwner->GetParaAttribs( nPara ) );
                         SvxNumRule aNewNumRule( *pDefaultBulletNumRule );
-                        aAttrs.Put( SvxNumBulletItem( aNewNumRule ), EE_PARA_NUMBULLET );
+                        aAttrs.Put( SvxNumBulletItem( aNewNumRule, EE_PARA_NUMBULLET ) );
                         pOwner->SetParaAttribs( nPara, aAttrs );
                     }
                 }
@@ -1089,7 +1089,7 @@ void OutlinerView::ApplyBulletsNumbering(
                         }
                     }
 
-                    aAttrs.Put(SvxNumBulletItem(aNewRule), EE_PARA_NUMBULLET);
+                    aAttrs.Put(SvxNumBulletItem(aNewRule, EE_PARA_NUMBULLET));
                 }
             }
             pOwner->SetParaAttribs(nPara, aAttrs);
diff --git a/editeng/source/uno/unoipset.cxx b/editeng/source/uno/unoipset.cxx
index dc3f774..40677da 100644
--- a/editeng/source/uno/unoipset.cxx
+++ b/editeng/source/uno/unoipset.cxx
@@ -181,7 +181,8 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa
         if( pNewItem->PutValue( aValue, nMemberId ) )
         {
             // Set new item in item set
-            rSet.Put( *pNewItem, pMap->nWID );
+            pNewItem->SetWhich( pMap->nWID );
+            rSet.Put( *pNewItem );
         }
         delete pNewItem;
     }
diff --git a/extensions/source/propctrlr/fontdialog.cxx b/extensions/source/propctrlr/fontdialog.cxx
index 8682604..89461f2 100644
--- a/extensions/source/propctrlr/fontdialog.cxx
+++ b/extensions/source/propctrlr/fontdialog.cxx
@@ -248,17 +248,17 @@ namespace pcr
             SvxCharReliefItem aFontReliefItem((FontRelief)nFontRelief, CFID_RELIEF);
             SvxEmphasisMarkItem aEmphasisMarkitem((FontEmphasisMark)nFontEmphasisMark, CFID_EMPHASIS);
 
-            _pSet->Put(aFontItem, CFID_FONT);
-            _pSet->Put(aSvxFontHeightItem,CFID_HEIGHT);
-            _pSet->Put(aWeightItem, CFID_WEIGHT);
-            _pSet->Put(aPostureItem, CFID_POSTURE);
-            _pSet->Put(aLanguageItem, CFID_LANGUAGE);
-            _pSet->Put(aUnderlineItem,CFID_UNDERLINE);
-            _pSet->Put(aCrossedOutItem,CFID_STRIKEOUT);
-            _pSet->Put(aWordLineModeItem, CFID_WORDLINEMODE);
-            _pSet->Put(aSvxColorItem, CFID_CHARCOLOR);
-            _pSet->Put(aFontReliefItem, CFID_RELIEF);
-            _pSet->Put(aEmphasisMarkitem, CFID_EMPHASIS);
+            _pSet->Put(aFontItem);
+            _pSet->Put(aSvxFontHeightItem);
+            _pSet->Put(aWeightItem);
+            _pSet->Put(aPostureItem);
+            _pSet->Put(aLanguageItem);
+            _pSet->Put(aUnderlineItem);
+            _pSet->Put(aCrossedOutItem);
+            _pSet->Put(aWordLineModeItem);
+            _pSet->Put(aSvxColorItem);
+            _pSet->Put(aFontReliefItem);
+            _pSet->Put(aEmphasisMarkitem);
 
             aPropExtractor.invalidateItem(PROPERTY_FONT_NAME, CFID_FONT, *_pSet);
             aPropExtractor.invalidateItem(PROPERTY_FONT_HEIGHT, CFID_HEIGHT, *_pSet);
diff --git a/filter/source/msfilter/svdfppt.cxx b/filter/source/msfilter/svdfppt.cxx
index 9d23b39..39d15be 100644
--- a/filter/source/msfilter/svdfppt.cxx
+++ b/filter/source/msfilter/svdfppt.cxx
@@ -6283,7 +6283,9 @@ void PPTParagraphObj::ApplyTo( SfxItemSet& rSet,  boost::optional< sal_Int16 >&
             pPortion->GetAttrib( PPT_CharAttr_FontHeight, nFontHeight, nDestinationInstance );
             nVal2 = -(sal_Int16)( ( nFontHeight * nVal * 8 ) / 100 );
         }
-        rSet.Put( SdrTextFixedCellHeightItem( true ), SDRATTR_TEXT_USEFIXEDCELLHEIGHT );
+        SdrTextFixedCellHeightItem aHeightItem(true);
+        aHeightItem.SetWhich(SDRATTR_TEXT_USEFIXEDCELLHEIGHT);
+        rSet.Put( aHeightItem );
         SvxLineSpacingItem aItem( 200, EE_PARA_SBL );
         if ( nVal2 <= 0 ) {
             aItem.SetLineHeight( (sal_uInt16)( rManager.ScalePoint( -nVal2 ) / 8 ) );
diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index adfcf06..7651102 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -124,7 +124,9 @@ public:
     inline void                 SetParent( const SfxItemSet* pNew );
 
     // add, delete items, work on items
+protected:
     virtual const SfxPoolItem*  Put( const SfxPoolItem&, sal_uInt16 nWhich );
+public:
     const SfxPoolItem*          Put( const SfxPoolItem& rItem )
                                 { return Put(rItem, rItem.Which()); }
     bool                        Put( const SfxItemSet&,
diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx
index f1f47a3..f2f9f29 100644
--- a/include/svl/poolitem.hxx
+++ b/include/svl/poolitem.hxx
@@ -163,7 +163,12 @@ protected:
 public:
     virtual                  ~SfxPoolItem();
 
-    void                     SetWhich( sal_uInt16 nId ) { m_nWhich = nId; }
+    void                     SetWhich( sal_uInt16 nId )
+                             {
+                                 // can only change the Which before we are in a set
+                                 assert(m_nRefCount==0);
+                                 m_nWhich = nId;
+                             }
     sal_uInt16               Which() const { return m_nWhich; }
     virtual bool             operator==( const SfxPoolItem& ) const = 0;
     bool                     operator!=( const SfxPoolItem& rItem ) const
@@ -186,6 +191,8 @@ public:
     virtual SfxPoolItem*     Create( SvStream &, sal_uInt16 nItemVersion ) const;
     virtual SvStream&        Store( SvStream &, sal_uInt16 nItemVersion ) const;
     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = nullptr ) const = 0;
+    // clone and call SetWhich
+    SfxPoolItem*             CloneSetWhich( sal_uInt16 nNewWhich ) const;
 
     sal_uLong                GetRefCount() const { return m_nRefCount; }
     inline SfxItemKind       GetKind() const { return m_nKind; }
diff --git a/reportdesign/source/ui/misc/UITools.cxx b/reportdesign/source/ui/misc/UITools.cxx
index d2e7f46..c509a0d 100644
--- a/reportdesign/source/ui/misc/UITools.cxx
+++ b/reportdesign/source/ui/misc/UITools.cxx
@@ -277,7 +277,8 @@ namespace
                 {
                     ::std::unique_ptr<SfxPoolItem> pClone(pItem->Clone());
                     pClone->PutValue(_xShape->getPropertyValue(aIt->sName), aIt->nMemberId);
-                    _rItemSet.Put(*pClone, aIt->nWID);
+                    pClone->SetWhich(aIt->nWID);
+                    _rItemSet.Put(*pClone);
                 }
             }
             ++aIt;
diff --git a/sc/source/core/data/stlpool.cxx b/sc/source/core/data/stlpool.cxx
index c9acb13..ec06c08 100644
--- a/sc/source/core/data/stlpool.cxx
+++ b/sc/source/core/data/stlpool.cxx
@@ -329,8 +329,10 @@ void ScStyleSheetPool::CreateStandardStyles()
 
     // distance to header/footer for the sheet
     pHFSetItem = new SvxSetItem( static_cast<const SvxSetItem&>(pSet->Get( ATTR_PAGE_HEADERSET ) ) );
-    pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
-    pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
+    pHFSetItem->SetWhich(ATTR_PAGE_HEADERSET);
+    pSet->Put( *pHFSetItem );
+    pHFSetItem->SetWhich(ATTR_PAGE_FOOTERSET);
+    pSet->Put( *pHFSetItem );
     delete pHFSetItem;
 
     // Header:
@@ -387,8 +389,10 @@ void ScStyleSheetPool::CreateStandardStyles()
     pHFSet->Put( SvxBrushItem( aColGrey, ATTR_BACKGROUND ) );
     pHFSet->Put( aBoxItem );
     pHFSet->Put( aBoxInfoItem );
-    pSet->Put( *pHFSetItem, ATTR_PAGE_HEADERSET );
-    pSet->Put( *pHFSetItem, ATTR_PAGE_FOOTERSET );
+    pHFSetItem->SetWhich(ATTR_PAGE_HEADERSET);
+    pSet->Put( *pHFSetItem );
+    pHFSetItem->SetWhich(ATTR_PAGE_FOOTERSET);
+    pSet->Put( *pHFSetItem );
     delete pHFSetItem;
 
     // Footer:
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index 77078ea..30f302d 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -192,8 +192,10 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                         rHFSet.Put( aHFDistItem );
                         rHFSet.Put( SvxLRSpaceItem( 0,0,0,0, ATTR_LRSPACE ) ); // Set border to Null
 
-                        pSet->Put( aHFSetItem, ATTR_PAGE_HEADERSET );
-                        pSet->Put( aHFSetItem, ATTR_PAGE_FOOTERSET );
+                        aHFSetItem.SetWhich(ATTR_PAGE_HEADERSET);
+                        pSet->Put( aHFSetItem );
+                        aHFSetItem.SetWhich(ATTR_PAGE_FOOTERSET);
+                        pSet->Put( aHFSetItem );
                         pSet->Put( aBoxInfoItem ); // Do not overwrite PoolDefault
                                                    // due to format templates
 
@@ -204,7 +206,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                         //  The page default depends on the system language.
                         SvxFrameDirection eDirection = ScGlobal::IsSystemRTL() ?
                                         FRMDIR_HORI_RIGHT_TOP : FRMDIR_HORI_LEFT_TOP;
-                        pSet->Put( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ), ATTR_WRITINGDIR );
+                        pSet->Put( SvxFrameDirectionItem( eDirection, ATTR_WRITINGDIR ) );
 
                         rItemPool.SetPoolDefaultItem( aPageItem );
                         rItemPool.SetPoolDefaultItem( aPaperSizeItem );
diff --git a/sc/source/core/tool/autoform.cxx b/sc/source/core/tool/autoform.cxx
index 69dfd23..5f03d87 100644
--- a/sc/source/core/tool/autoform.cxx
+++ b/sc/source/core/tool/autoform.cxx
@@ -657,9 +657,15 @@ void ScAutoFormatData::FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, S
         }
         else
         {
-            rItemSet.Put( rField.GetHeight(), ATTR_CJK_FONT_HEIGHT );
-            rItemSet.Put( rField.GetWeight(), ATTR_CJK_FONT_WEIGHT );
-            rItemSet.Put( rField.GetPosture(), ATTR_CJK_FONT_POSTURE );
+            SvxFontHeightItem aFontHeightItem(rField.GetHeight());
+            aFontHeightItem.SetWhich(ATTR_CJK_FONT_HEIGHT);
+            rItemSet.Put( aFontHeightItem );
+            SvxWeightItem aWeightItem(rField.GetWeight());
+            aWeightItem.SetWhich(ATTR_CJK_FONT_WEIGHT);
+            rItemSet.Put( aWeightItem );
+            SvxPostureItem aPostureItem(rField.GetPosture());
+            aPostureItem.SetWhich(ATTR_CJK_FONT_POSTURE);
+            rItemSet.Put( aPostureItem );
         }
         // do not insert empty CTL font
         const SvxFontItem& rCTLFont = rField.GetCTLFont();
@@ -672,9 +678,15 @@ void ScAutoFormatData::FillToItemSet( sal_uInt16 nIndex, SfxItemSet& rItemSet, S
         }
         else
         {
-            rItemSet.Put( rField.GetHeight(), ATTR_CTL_FONT_HEIGHT );
-            rItemSet.Put( rField.GetWeight(), ATTR_CTL_FONT_WEIGHT );
-            rItemSet.Put( rField.GetPosture(), ATTR_CTL_FONT_POSTURE );
+            SvxFontHeightItem aFontHeightItem(rField.GetHeight());
+            aFontHeightItem.SetWhich(ATTR_CTL_FONT_HEIGHT);
+            rItemSet.Put( aFontHeightItem );
+            SvxWeightItem aWeightItem(rField.GetWeight());
+            aWeightItem.SetWhich(ATTR_CTL_FONT_WEIGHT);
+            rItemSet.Put( aWeightItem );
+            SvxPostureItem aPostureItem(rField.GetPosture());
+            aPostureItem.SetWhich(ATTR_CTL_FONT_POSTURE);
+            rItemSet.Put( aPostureItem );
         }
         rItemSet.Put( rField.GetUnderline() );
         rItemSet.Put( rField.GetOverline() );
diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx
index 46d9d28..80a9a63 100644
--- a/sc/source/filter/excel/xlroot.cxx
+++ b/sc/source/filter/excel/xlroot.cxx
@@ -369,9 +369,12 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const
         SfxItemSet aItemSet( *GetDoc().GetPool(), ATTR_PATTERN_START, ATTR_PATTERN_END );
         ScPatternAttr::FillToEditItemSet( *pEditSet, aItemSet );
         // FillToEditItemSet() adjusts font height to 1/100th mm, we need twips
-        pEditSet->Put( aItemSet.Get( ATTR_FONT_HEIGHT ), EE_CHAR_FONTHEIGHT );
-        pEditSet->Put( aItemSet.Get( ATTR_CJK_FONT_HEIGHT ), EE_CHAR_FONTHEIGHT_CJK );
-        pEditSet->Put( aItemSet.Get( ATTR_CTL_FONT_HEIGHT ), EE_CHAR_FONTHEIGHT_CTL );
+        std::unique_ptr<SfxPoolItem> pNewItem( aItemSet.Get( ATTR_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT));
+        pEditSet->Put( *pNewItem );
+        pNewItem.reset( aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK));
+        pEditSet->Put( *pNewItem );
+        pNewItem.reset( aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL));
+        pEditSet->Put( *pNewItem );
         rEE.SetDefaults( pEditSet );    // takes ownership
    }
     return *mrData.mxHFEditEngine;
diff --git a/sc/source/filter/ftools/ftools.cxx b/sc/source/filter/ftools/ftools.cxx
index e40967b..19616c5 100644
--- a/sc/source/filter/ftools/ftools.cxx
+++ b/sc/source/filter/ftools/ftools.cxx
@@ -217,7 +217,10 @@ bool ScfTools::CheckItems( const SfxItemSet& rItemSet, const sal_uInt16* pnWhich
 void ScfTools::PutItem( SfxItemSet& rItemSet, const SfxPoolItem& rItem, sal_uInt16 nWhichId, bool bSkipPoolDef )
 {
     if( !bSkipPoolDef || (rItem != rItemSet.GetPool()->GetDefaultItem( nWhichId )) )
-        rItemSet.Put( rItem, nWhichId );
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(rItem.CloneSetWhich(nWhichId));
+        rItemSet.Put( *pNewItem );
+    }
 }
 
 void ScfTools::PutItem( SfxItemSet& rItemSet, const SfxPoolItem& rItem, bool bSkipPoolDef )
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 77e0c9b..da9bb2f 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -267,17 +267,29 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
                         if ( nScriptType & nScript )
                         {
                             if ( pFont )
-                                rSet.Put( *pFont, ScGlobal::GetScriptedWhichID(
-                                            nScript, ATTR_FONT ));
+                            {
+                                std::unique_ptr<SfxPoolItem> pNewItem(pFont->CloneSetWhich(
+                                        ScGlobal::GetScriptedWhichID(nScript, ATTR_FONT )));
+                                rSet.Put( *pNewItem );
+                            }
                             if ( pHeight )
-                                rSet.Put( *pHeight, ScGlobal::GetScriptedWhichID(
-                                            nScript, ATTR_FONT_HEIGHT ));
+                            {
+                                std::unique_ptr<SfxPoolItem> pNewItem(pHeight->CloneSetWhich(
+                                        ScGlobal::GetScriptedWhichID(nScript, ATTR_FONT_HEIGHT )));
+                                rSet.Put( *pNewItem );
+                            }
                             if ( pWeight )
-                                rSet.Put( *pWeight, ScGlobal::GetScriptedWhichID(
-                                            nScript, ATTR_FONT_WEIGHT ));
+                            {
+                                std::unique_ptr<SfxPoolItem> pNewItem(pWeight->CloneSetWhich(
+                                        ScGlobal::GetScriptedWhichID(nScript, ATTR_FONT_WEIGHT )));
+                                rSet.Put( *pNewItem );
+                            }
                             if ( pPosture )
-                                rSet.Put( *pPosture, ScGlobal::GetScriptedWhichID(
-                                            nScript, ATTR_FONT_POSTURE ));
+                            {
+                                std::unique_ptr<SfxPoolItem> pNewItem(pPosture->CloneSetWhich(
+                                        ScGlobal::GetScriptedWhichID(nScript, ATTR_FONT_POSTURE )));
+                                rSet.Put( *pNewItem );
+                            }
                         }
                     }
                 }
diff --git a/sc/source/filter/starcalc/scflt.cxx b/sc/source/filter/starcalc/scflt.cxx
index bfac4b0..0d7f37c 100644
--- a/sc/source/filter/starcalc/scflt.cxx
+++ b/sc/source/filter/starcalc/scflt.cxx
@@ -715,23 +715,21 @@ void Sc10PageCollection::PutToDoc( ScDocument* pDoc )
             aEditAttribs.Put(   SvxFontItem(
                                     eFam,
                                     SC10TOSTRING( pHeadFootLine->LogFont.lfFaceName ), EMPTY_OUSTRING,
-                                    PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ),
-                                EE_CHAR_FONTINFO );
-            aEditAttribs.Put(   SvxFontHeightItem( std::abs( pHeadFootLine->LogFont.lfHeight ), 100, EE_CHAR_FONTHEIGHT ),
-                                EE_CHAR_FONTHEIGHT);
+                                    PITCH_DONTKNOW, RTL_TEXTENCODING_DONTKNOW, EE_CHAR_FONTINFO ) );
+            aEditAttribs.Put(   SvxFontHeightItem( std::abs( pHeadFootLine->LogFont.lfHeight ), 100, EE_CHAR_FONTHEIGHT ) );
 
             Sc10Color nColor = pHeadFootLine->TextColor;
             Color TextColor( nColor.Red, nColor.Green, nColor.Blue );
-            aEditAttribs.Put(SvxColorItem(TextColor, EE_CHAR_COLOR), EE_CHAR_COLOR);
+            aEditAttribs.Put(SvxColorItem(TextColor, EE_CHAR_COLOR));
             // FontAttr
             if (pHeadFootLine->LogFont.lfWeight != fwNormal)
-                aEditAttribs.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT), EE_CHAR_WEIGHT);
+                aEditAttribs.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
             if (pHeadFootLine->LogFont.lfItalic != 0)
-                aEditAttribs.Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC), EE_CHAR_ITALIC);
+                aEditAttribs.Put(SvxPostureItem(ITALIC_NORMAL, EE_CHAR_ITALIC));
             if (pHeadFootLine->LogFont.lfUnderline != 0)
-                aEditAttribs.Put(SvxUnderlineItem(LINESTYLE_SINGLE, EE_CHAR_UNDERLINE), EE_CHAR_UNDERLINE);
+                aEditAttribs.Put(SvxUnderlineItem(LINESTYLE_SINGLE, EE_CHAR_UNDERLINE));
             if (pHeadFootLine->LogFont.lfStrikeOut != 0)
-                aEditAttribs.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT), EE_CHAR_STRIKEOUT);
+                aEditAttribs.Put(SvxCrossedOutItem(STRIKEOUT_SINGLE, EE_CHAR_STRIKEOUT));
             OUString aText( pHeadFootLine->Title, strlen(pHeadFootLine->Title), DEFCHARSET );
             aEditEngine.SetText( aText );
             aEditEngine.QuickSetAttribs( aEditAttribs, ESelection( 0, 0, 0, aText.getLength() ) );
diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx
index 17eb94d..5c4e0c1 100644
--- a/sc/source/ui/Accessibility/AccessibleText.cxx
+++ b/sc/source/ui/Accessibility/AccessibleText.cxx
@@ -1427,9 +1427,12 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
         rPattern.FillEditItemSet( &aDefaults );
         //  FillEditItemSet adjusts font height to 1/100th mm,
         //  but for header/footer twips is needed, as in the PatternAttr:
-        aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
-        aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
-        aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+        std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
+        aDefaults.Put( *pNewItem );
+        pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK));
+        aDefaults.Put( *pNewItem );
+        pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL));
+        aDefaults.Put( *pNewItem );
         aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
         pHdrEngine->SetDefaults( aDefaults );
 
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 86cf706..882dfdd 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1237,20 +1237,35 @@ void ScTextWnd::StartEditEngine()
 static void lcl_ExtendEditFontAttribs( SfxItemSet& rSet )
 {
     const SfxPoolItem& rFontItem = rSet.Get( EE_CHAR_FONTINFO );
-    rSet.Put( rFontItem, EE_CHAR_FONTINFO_CJK );
-    rSet.Put( rFontItem, EE_CHAR_FONTINFO_CTL );
+    std::unique_ptr<SfxPoolItem> pNewItem(rFontItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_FONTINFO_CJK);
+    rSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_FONTINFO_CTL);
+    rSet.Put( *pNewItem );
     const SfxPoolItem& rHeightItem = rSet.Get( EE_CHAR_FONTHEIGHT );
-    rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CJK );
-    rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CTL );
+    pNewItem.reset(rHeightItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_FONTHEIGHT_CJK);
+    rSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_FONTHEIGHT_CTL);
+    rSet.Put( *pNewItem );
     const SfxPoolItem& rWeightItem = rSet.Get( EE_CHAR_WEIGHT );
-    rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
-    rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+    pNewItem.reset(rWeightItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_WEIGHT_CJK);
+    rSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_WEIGHT_CTL);
+    rSet.Put( *pNewItem );
     const SfxPoolItem& rItalicItem = rSet.Get( EE_CHAR_ITALIC );
-    rSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
-    rSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+    pNewItem.reset(rItalicItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_ITALIC_CJK);
+    rSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_ITALIC_CTL);
+    rSet.Put( *pNewItem );
     const SfxPoolItem& rLangItem = rSet.Get( EE_CHAR_LANGUAGE );
-    rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
-    rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+    pNewItem.reset(rLangItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_LANGUAGE_CJK);
+    rSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_LANGUAGE_CTL);
+    rSet.Put( *pNewItem );
 }
 
 static void lcl_ModifyRTLDefaults( SfxItemSet& rSet )
diff --git a/sc/source/ui/dbgui/csvgrid.cxx b/sc/source/ui/dbgui/csvgrid.cxx
index 10ac546..e2a8ec2 100644
--- a/sc/source/ui/dbgui/csvgrid.cxx
+++ b/sc/source/ui/dbgui/csvgrid.cxx
@@ -251,14 +251,23 @@ void ScCsvGrid::InitFonts()
 
     // copy other items from default font
     const SfxPoolItem& rWeightItem = aDefSet.Get( EE_CHAR_WEIGHT );
-    aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK );
-    aDefSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL );
+    std::unique_ptr<SfxPoolItem> pNewItem(rWeightItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_WEIGHT_CJK);
+    aDefSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_WEIGHT_CTL);
+    aDefSet.Put( *pNewItem );
     const SfxPoolItem& rItalicItem = aDefSet.Get( EE_CHAR_ITALIC );
-    aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK );
-    aDefSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL );
+    pNewItem.reset(rItalicItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_ITALIC_CJK);
+    aDefSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_ITALIC_CTL);
+    aDefSet.Put( *pNewItem );
     const SfxPoolItem& rLangItem = aDefSet.Get( EE_CHAR_LANGUAGE );
-    aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK );
-    aDefSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL );
+    pNewItem.reset(rLangItem.Clone());
+    pNewItem->SetWhich(EE_CHAR_LANGUAGE_CJK);
+    aDefSet.Put( *pNewItem );
+    pNewItem->SetWhich(EE_CHAR_LANGUAGE_CTL);
+    aDefSet.Put( *pNewItem );
 
     mpEditEngine->SetDefaults( aDefSet );
     InvalidateGfx();
diff --git a/sc/source/ui/drawfunc/drawsh.cxx b/sc/source/ui/drawfunc/drawsh.cxx
index 200d5a9..35a0639 100644
--- a/sc/source/ui/drawfunc/drawsh.cxx
+++ b/sc/source/ui/drawfunc/drawsh.cxx
@@ -334,11 +334,11 @@ void ScDrawShell::ExecuteMacroAssign( SdrObject* pObj, vcl::Window* pWin )
 
     // create empty itemset for macro-dlg
     std::unique_ptr<SfxItemSet> pItemSet(new SfxItemSet(SfxGetpApp()->GetPool(), SID_ATTR_MACROITEM, SID_ATTR_MACROITEM, SID_EVENTCONFIG, SID_EVENTCONFIG, 0 ));
-    pItemSet->Put ( aItem, SID_ATTR_MACROITEM );
+    pItemSet->Put ( aItem );
 
     SfxEventNamesItem aNamesItem(SID_EVENTCONFIG);
     aNamesItem.AddEvent( ScResId(RID_SCSTR_ONCLICK), OUString(), SFX_EVENT_MOUSECLICK_OBJECT );
-    pItemSet->Put( aNamesItem, SID_EVENTCONFIG );
+    pItemSet->Put( aNamesItem );
 
     css::uno::Reference < css::frame::XFrame > xFrame;
     if (GetViewShell())
diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx
index 8bccbcc..f9eaeac 100644
--- a/sc/source/ui/pagedlg/tphfedit.cxx
+++ b/sc/source/ui/pagedlg/tphfedit.cxx
@@ -160,9 +160,12 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
     rPattern.FillEditItemSet( pSet );
     //  FillEditItemSet adjusts font height to 1/100th mm,
     //  but for header/footer twips is needed, as in the PatternAttr:
-    pSet->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
-    pSet->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
-    pSet->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+    std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
+    pSet->Put( *pNewItem );
+    pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK));
+    pSet->Put( *pNewItem );
+    pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL));
+    pSet->Put( *pNewItem );
     if (mbRTL)
         pSet->Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) );
     pEdEngine->SetDefaults( pSet );
diff --git a/sc/source/ui/unoobj/textuno.cxx b/sc/source/ui/unoobj/textuno.cxx
index 3c9cbf3..67e2acb 100644
--- a/sc/source/ui/unoobj/textuno.cxx
+++ b/sc/source/ui/unoobj/textuno.cxx
@@ -221,9 +221,12 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder()
         rPattern.FillEditItemSet( &aDefaults );
         //  FillEditItemSet adjusts font height to 1/100th mm,
         //  but for header/footer twips is needed, as in the PatternAttr:
-        aDefaults.Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
-        aDefaults.Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
-        aDefaults.Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+        std::unique_ptr<SfxPoolItem> pNewItem( rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) );
+        aDefaults.Put( *pNewItem );
+        pNewItem.reset( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) );
+        aDefaults.Put( *pNewItem );
+        pNewItem.reset( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) );
+        aDefaults.Put( *pNewItem );
         pHdrEngine->SetDefaults( aDefaults );
 
         ScHeaderFieldData aData;
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index b7af7e0..3fb44d5 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -2183,7 +2183,8 @@ void ScFormatShell::GetAttrState( SfxItemSet& rSet )
             break;
             case SID_ATTR_BRUSH:
             {
-                rSet.Put( rBrushItem, GetPool().GetWhich(nWhich) );
+                std::unique_ptr<SfxPoolItem> pNewItem(rBrushItem.CloneSetWhich(GetPool().GetWhich(nWhich)));
+                rSet.Put( *pNewItem );
             }
             break;
         }
diff --git a/sc/source/ui/view/printfun.cxx b/sc/source/ui/view/printfun.cxx
index 292b9d1..a1ec9e6 100644
--- a/sc/source/ui/view/printfun.cxx
+++ b/sc/source/ui/view/printfun.cxx
@@ -1701,9 +1701,12 @@ void ScPrintFunc::MakeEditEngine()
         rPattern.FillEditItemSet( pEditDefaults );
         //  FillEditItemSet adjusts font height to 1/100th mm,
         //  but for header/footer twips is needed, as in the PatternAttr:
-        pEditDefaults->Put( rPattern.GetItem(ATTR_FONT_HEIGHT), EE_CHAR_FONTHEIGHT );
-        pEditDefaults->Put( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CJK );
-        pEditDefaults->Put( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT), EE_CHAR_FONTHEIGHT_CTL );
+        std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
+        pEditDefaults->Put( *pNewItem );
+        pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK));
+        pEditDefaults->Put( *pNewItem );
+        pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL));
+        pEditDefaults->Put( *pNewItem );
         //  don't use font color, because background color is not used
         //! there's no way to set the background for note pages
         pEditDefaults->ClearItem( EE_CHAR_COLOR );
diff --git a/sc/source/ui/view/viewutil.cxx b/sc/source/ui/view/viewutil.cxx
index 3b28999..958a042 100644
--- a/sc/source/ui/view/viewutil.cxx
+++ b/sc/source/ui/view/viewutil.cxx
@@ -64,7 +64,10 @@ void ScViewUtil::PutItemScript( SfxItemSet& rShellSet, const SfxItemSet& rCoreSe
     aSetItem.GetItemSet().PutExtended( rCoreSet, SfxItemState::DONTCARE, SfxItemState::SET );
     const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScript );
     if (pI)
-        rShellSet.Put( *pI, nWhichId );
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(pI->CloneSetWhich(nWhichId));
+        rShellSet.Put( *pNewItem );
+    }
     else
         rShellSet.InvalidateItem( nWhichId );
 }
diff --git a/sd/source/ui/dlg/dlgolbul.cxx b/sd/source/ui/dlg/dlgolbul.cxx
index 89ee17d..4fbeeb6 100644
--- a/sd/source/ui/dlg/dlgolbul.cxx
+++ b/sd/source/ui/dlg/dlgolbul.cxx
@@ -106,7 +106,8 @@ OutlineBulletDlg::OutlineBulletDlg(
 
         DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in Pool! [CL]" );
 
-        aInputSet.Put(*pItem, EE_PARA_NUMBULLET);
+        std::unique_ptr<SfxPoolItem> pNewItem(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
+        aInputSet.Put(*pNewItem);
     }
 
     if(bTitle && aInputSet.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET )
diff --git a/sd/source/ui/func/fubullet.cxx b/sd/source/ui/func/fubullet.cxx
index 6ff754a..666952a 100644
--- a/sd/source/ui/func/fubullet.cxx
+++ b/sd/source/ui/func/fubullet.cxx
@@ -266,8 +266,10 @@ void FuBullet::InsertSpecialCharacter( SfxRequest& rReq )
                                    aFont.GetCharSet(),
                                    EE_CHAR_FONTINFO);
             aSet.Put(aFontItem);
-            aSet.Put(aFontItem, EE_CHAR_FONTINFO_CJK);
-            aSet.Put(aFontItem, EE_CHAR_FONTINFO_CTL);
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK);
+            aSet.Put(aFontItem);
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL);
+            aSet.Put(aFontItem);
             pOV->SetAttribs(aSet);
 
             ESelection aSel = pOV->GetSelection();
diff --git a/sd/source/ui/func/fuolbull.cxx b/sd/source/ui/func/fuolbull.cxx
index a67537f..064c6b8 100644
--- a/sd/source/ui/func/fuolbull.cxx
+++ b/sd/source/ui/func/fuolbull.cxx
@@ -269,7 +269,7 @@ void FuOutlineBullet::SetCurrentBulletsNumbering(SfxRequest& rReq)
     if ( bInMasterView )
     {
         SfxItemSet aSetAttr( mpViewShell->GetPool(), EE_ITEMS_START, EE_ITEMS_END );
-        aSetAttr.Put(SvxNumBulletItem( *pNumRule ), nNumItemId);
+        aSetAttr.Put(SvxNumBulletItem( *pNumRule, nNumItemId ));
         mpView->SetAttributes(aSetAttr);
     }
 
@@ -344,7 +344,8 @@ const SfxPoolItem* FuOutlineBullet::GetNumBulletItem(SfxItemSet& aNewAttr, sal_u
 
             //DBG_ASSERT( pItem, "No EE_PARA_NUMBULLET in the Pool!" );
 
-            aNewAttr.Put(*pItem, EE_PARA_NUMBULLET);
+            std::unique_ptr<SfxPoolItem> pNewItem(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
+            aNewAttr.Put(*pNewItem);
 
             if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET )
             {
diff --git a/sd/source/ui/view/drtxtob.cxx b/sd/source/ui/view/drtxtob.cxx
index 25e0e44..237a451 100644
--- a/sd/source/ui/view/drtxtob.cxx
+++ b/sd/source/ui/view/drtxtob.cxx
@@ -215,11 +215,13 @@ void TextObjectBar::GetAttrState( SfxItemSet& rSet )
                     {
                         SvxFontHeightItem aFontItem = dynamic_cast<const SvxFontHeightItem&>(*pI);
                         aFontItem.SetHeight(aFontItem.GetHeight(), stretchX, aFontItem.GetPropUnit());
-                        aAttrSet.Put( aFontItem, nWhich );
+                        aFontItem.SetWhich(nWhich);
+                        aAttrSet.Put( aFontItem );
                     }
                     else
                     {
-                        aAttrSet.Put( *pI, nWhich );
+                        std::unique_ptr<SfxPoolItem> pNewItem(pI->CloneSetWhich(nWhich));
+                        aAttrSet.Put( *pNewItem );
                     }
                 }
                 else
diff --git a/sd/source/ui/view/drviews9.cxx b/sd/source/ui/view/drviews9.cxx
index 1678b78..2e0b5db 100644
--- a/sd/source/ui/view/drviews9.cxx
+++ b/sd/source/ui/view/drviews9.cxx
@@ -219,7 +219,9 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                     if (CHECK_RANGE (drawing::FillStyle_NONE, (sal_Int32)pFillStyle->GetValue (), drawing::FillStyle_BITMAP))
                     {
                         pAttr->ClearItem (XATTR_FILLSTYLE);
-                        pAttr->Put (XFillStyleItem ((drawing::FillStyle) pFillStyle->GetValue ()), XATTR_FILLSTYLE);
+                        XFillStyleItem aStyleItem((drawing::FillStyle) pFillStyle->GetValue ());
+                        aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                        pAttr->Put (aStyleItem);
                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
                         rBindings.Invalidate (SID_ATTR_PAGE_FILLSTYLE);
                     }
@@ -242,7 +244,9 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                     if (CHECK_RANGE (drawing::LineStyle_NONE, (sal_Int32)pLineStyle->GetValue (), drawing::LineStyle_DASH))
                     {
                         pAttr->ClearItem (XATTR_LINESTYLE);
-                        pAttr->Put (XLineStyleItem ((drawing::LineStyle) pLineStyle->GetValue ()), XATTR_LINESTYLE);
+                        XLineStyleItem aStyleItem((drawing::LineStyle) pLineStyle->GetValue());
+                        aStyleItem.SetWhich(XATTR_LINESTYLE);
+                        pAttr->Put(aStyleItem);
                         rBindings.Invalidate (SID_ATTR_LINE_STYLE);
                     }
 #if HAVE_FEATURE_SCRIPTING
@@ -262,7 +266,9 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                 {
                     const SfxUInt32Item* pLineWidth = rReq.GetArg<SfxUInt32Item>(ID_VAL_WIDTH);
                     pAttr->ClearItem (XATTR_LINEWIDTH);
-                    pAttr->Put (XLineWidthItem (pLineWidth->GetValue ()), XATTR_LINEWIDTH);
+                    XLineWidthItem aWidthItem(pLineWidth->GetValue());
+                    aWidthItem.SetWhich(XATTR_LINEWIDTH);
+                    pAttr->Put(aWidthItem);
                     rBindings.Invalidate (SID_ATTR_LINE_WIDTH);
                     break;
                 }
@@ -281,11 +287,11 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
 
                     pAttr->ClearItem (XATTR_FILLCOLOR);
                     pAttr->ClearItem (XATTR_FILLSTYLE);
-                    pAttr->Put (XFillColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
+                    XFillColorItem aColorItem(-1, Color ((sal_uInt8) pRed->GetValue (),
                                                            (sal_uInt8) pGreen->GetValue (),
-                                                           (sal_uInt8) pBlue->GetValue ())),
-                                XATTR_FILLCOLOR);
-                    pAttr->Put (XFillStyleItem (drawing::FillStyle_SOLID), XATTR_FILLSTYLE);
+                                                           (sal_uInt8) pBlue->GetValue ()));
+                    aColorItem.SetWhich(XATTR_FILLCOLOR);
+                    pAttr->Put(aColorItem);
                     rBindings.Invalidate (SID_ATTR_FILL_COLOR);
                     rBindings.Invalidate (SID_ATTR_PAGE_COLOR);
                     rBindings.Invalidate (SID_ATTR_FILL_STYLE);
@@ -306,10 +312,11 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                     const SfxUInt32Item* pBlue = rReq.GetArg<SfxUInt32Item>(ID_VAL_BLUE);
 
                     pAttr->ClearItem (XATTR_LINECOLOR);
-                    pAttr->Put (XLineColorItem (-1, Color ((sal_uInt8) pRed->GetValue (),
-                                                           (sal_uInt8) pGreen->GetValue (),
-                                                           (sal_uInt8) pBlue->GetValue ())),
-                                XATTR_LINECOLOR);
+                    XLineColorItem aColorItem(-1, Color((sal_uInt8) pRed->GetValue(),
+                                                        (sal_uInt8) pGreen->GetValue(),
+                                                        (sal_uInt8) pBlue->GetValue()));
+                    aColorItem.SetWhich(XATTR_LINECOLOR);
+                    pAttr->Put(aColorItem);
                     rBindings.Invalidate (SID_ATTR_LINE_COLOR);
                     break;
                 }
@@ -349,8 +356,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                             if (rReq.GetSlot () == SID_SETGRADSTARTCOLOR) aGradient.SetStartColor (aColor);
                             else aGradient.SetEndColor (aColor);
 
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+                            XFillStyleItem aStyleItem(drawing::FillStyle_GRADIENT);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillGradientItem aGradientItem(pName->GetValue (), aGradient);
+                            aGradientItem.SetWhich(XATTR_FILLGRADIENT);
+                            pAttr->Put(aGradientItem);
                             break;
                         }
                     }
@@ -367,8 +378,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
 
                         GetDoc()->GetGradientList ()->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
 
-                        pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
-                        pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+                        XFillStyleItem aStyleItem(drawing::FillStyle_GRADIENT);
+                        aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                        pAttr->Put(aStyleItem);
+                        XFillGradientItem aGradientItem(pName->GetValue(), aGradient);
+                        aGradientItem.SetWhich(XATTR_FILLGRADIENT);
+                        pAttr->Put(aGradientItem);
                     }
 
                     rBindings.Invalidate (SID_ATTR_FILL_STYLE);
@@ -411,8 +426,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
 
                             aHatch.SetColor (aColor);
 
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+                            XFillStyleItem aStyleItem(drawing::FillStyle_HATCH);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillHatchItem aHatchItem(pName->GetValue(), aHatch);
+                            aHatchItem.SetWhich(XATTR_FILLHATCH);
+                            pAttr->Put(aHatchItem);
                             break;
                         }
                     }
@@ -423,8 +442,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
 
                         GetDoc()->GetHatchList ()->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
 
-                        pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
-                        pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+                        XFillStyleItem aStyleItem(drawing::FillStyle_HATCH);
+                        aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                        pAttr->Put(aStyleItem);
+                        XFillHatchItem aHatchItem(pName->GetValue (), aHatch);
+                        aHatchItem.SetWhich(XATTR_FILLHATCH);
+                        pAttr->Put(aHatchItem);
                     }
 
                     rBindings.Invalidate (SID_ATTR_FILL_HATCH);
@@ -473,8 +496,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                         else
                             pDashList->Insert (pEntry);
 
-                        pAttr->Put (XLineDashItem (pName->GetValue (), aNewDash), XATTR_LINEDASH);
-                        pAttr->Put (XLineStyleItem (drawing::LineStyle_DASH), XATTR_LINESTYLE);
+                        XLineDashItem aDashItem(pName->GetValue(), aNewDash);
+                        aDashItem.SetWhich(XATTR_LINEDASH);
+                        pAttr->Put(aDashItem);
+                        XLineStyleItem aStyleItem(drawing::LineStyle_DASH);
+                        aStyleItem.SetWhich(XATTR_LINESTYLE);
+                        pAttr->Put(aStyleItem);
                         rBindings.Invalidate (SID_ATTR_LINE_DASH);
                         rBindings.Invalidate (SID_ATTR_FILL_STYLE);
                     }
@@ -533,8 +560,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                                 aGradient.SetStartIntens ((short) pStart->GetValue ());
                                 aGradient.SetEndIntens ((short) pEnd->GetValue ());
 
-                                pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
-                                pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+                                XFillStyleItem aStyleItem(drawing::FillStyle_GRADIENT);
+                                aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                                pAttr->Put(aStyleItem);
+                                XFillGradientItem aGradientItem(pName->GetValue (), aGradient);
+                                aGradientItem.SetWhich(XATTR_FILLGRADIENT);
+                                pAttr->Put(aGradientItem);
                                 break;
                             }
                         }
@@ -548,8 +579,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                                                  (short) pStart->GetValue (), (short) pEnd->GetValue ());
 
                             pGradientList->Insert (new XGradientEntry (aGradient, pName->GetValue ()));
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillGradientItem (pName->GetValue (), aGradient), XATTR_FILLGRADIENT);
+                            XFillStyleItem aStyleItem(drawing::FillStyle_GRADIENT);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillGradientItem aGradientItem(pName->GetValue (), aGradient);
+                            aGradientItem.SetWhich(XATTR_FILLGRADIENT);
+                            pAttr->Put(aGradientItem);;
                         }
 
                         rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
@@ -599,8 +634,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                                 aHatch.SetDistance (pDistance->GetValue ());
                                 aHatch.SetAngle (pAngle->GetValue () * 10);
 
-                                pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
-                                pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+                                XFillStyleItem aStyleItem(drawing::FillStyle_HATCH);
+                                aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                                pAttr->Put(aStyleItem);
+                                XFillHatchItem aHatchItem(pName->GetValue (), aHatch);
+                                aHatchItem.SetWhich(XATTR_FILLHATCH);
+                                pAttr->Put(aHatchItem);
                                 break;
                             }
                         }
@@ -612,8 +651,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                                            pAngle->GetValue () * 10);
 
                             pHatchList->Insert (new XHatchEntry (aHatch, pName->GetValue ()));
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillHatchItem (pName->GetValue (), aHatch), XATTR_FILLHATCH);
+                            XFillStyleItem aStyleItem(drawing::FillStyle_HATCH);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillHatchItem aHatchItem(pName->GetValue (), aHatch);
+                            aHatchItem.SetWhich(XATTR_FILLHATCH);
+                            pAttr->Put(aHatchItem);
                         }
 
                         rBindings.Invalidate (SID_ATTR_FILL_HATCH);
@@ -648,9 +691,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                         {
                             pAttr->ClearItem (XATTR_FILLGRADIENT);
                             pAttr->ClearItem (XATTR_FILLSTYLE);
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_GRADIENT), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillGradientItem (pName->GetValue (), pEntry->GetGradient ()), XATTR_FILLGRADIENT);
-
+                            XFillStyleItem aStyleItem(drawing::FillStyle_GRADIENT);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillGradientItem aGradientItem(pName->GetValue (), pEntry->GetGradient ());
+                            aGradientItem.SetWhich(XATTR_FILLGRADIENT);
+                            pAttr->Put(aGradientItem);
                             rBindings.Invalidate (SID_ATTR_FILL_GRADIENT);
                             rBindings.Invalidate (SID_ATTR_PAGE_GRADIENT);
                             rBindings.Invalidate (SID_ATTR_FILL_STYLE);
@@ -685,8 +731,12 @@ void DrawViewShell::AttrExec (SfxRequest &rReq)
                         {
                             pAttr->ClearItem (XATTR_FILLHATCH);
                             pAttr->ClearItem (XATTR_FILLSTYLE);
-                            pAttr->Put (XFillStyleItem (drawing::FillStyle_HATCH), XATTR_FILLSTYLE);
-                            pAttr->Put (XFillHatchItem (pName->GetValue (), pEntry->GetHatch ()), XATTR_FILLHATCH);
+                            XFillStyleItem aStyleItem(drawing::FillStyle_HATCH);
+                            aStyleItem.SetWhich(XATTR_FILLSTYLE);
+                            pAttr->Put(aStyleItem);
+                            XFillHatchItem aHatchItem(pName->GetValue (), pEntry->GetHatch ());
+                            aHatchItem.SetWhich(XATTR_FILLHATCH);
+                            pAttr->Put(aHatchItem);
 
                             rBindings.Invalidate (SID_ATTR_FILL_HATCH);
                             rBindings.Invalidate (SID_ATTR_PAGE_HATCH);
diff --git a/sd/source/ui/view/viewshel.cxx b/sd/source/ui/view/viewshel.cxx
index f76536b..07c2382 100644
--- a/sd/source/ui/view/viewshel.cxx
+++ b/sd/source/ui/view/viewshel.cxx
@@ -920,7 +920,8 @@ const SfxPoolItem* ViewShell::GetNumBulletItem(SfxItemSet& aNewAttr, sal_uInt16&
             if( pItem == nullptr )
                 pItem = static_cast<const SvxNumBulletItem*>( aNewAttr.GetPool()->GetSecondaryPool()->GetPoolDefaultItem(EE_PARA_NUMBULLET) );
 
-            aNewAttr.Put(*pItem, EE_PARA_NUMBULLET);
+            std::unique_ptr<SfxPoolItem> pNewItem(pItem->CloneSetWhich(EE_PARA_NUMBULLET));
+            aNewAttr.Put(*pNewItem);
 
             if(bTitle && aNewAttr.GetItemState(EE_PARA_NUMBULLET) == SfxItemState::SET )
             {
diff --git a/svl/source/items/itemprop.cxx b/svl/source/items/itemprop.cxx
index 2fe99b5..639c1f3 100644
--- a/svl/source/items/itemprop.cxx
+++ b/svl/source/items/itemprop.cxx
@@ -251,7 +251,7 @@ void SfxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry& rEn
             throw IllegalArgumentException();
         }
         // apply new item
-        rSet.Put( *pNewItem, rEntry.nWID );
+        rSet.Put( *pNewItem );
     }
 }
 
diff --git a/svl/source/items/poolitem.cxx b/svl/source/items/poolitem.cxx
index 4c3bb34..c559561 100644
--- a/svl/source/items/poolitem.cxx
+++ b/svl/source/items/poolitem.cxx
@@ -195,6 +195,15 @@ void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
     xmlTextWriterEndElement(pWriter);
 }
+
+SfxPoolItem* SfxPoolItem::CloneSetWhich( sal_uInt16 nNewWhich ) const
+{
+    SfxPoolItem* pItem = Clone();
+    pItem->SetWhich(nNewWhich);
+    return pItem;
+}
+
+
 SfxPoolItem* SfxVoidItem::CreateDefault()
 {
     return new SfxVoidItem(0);
diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx
index 3adfe28..6d38b34 100644
--- a/svx/source/dialog/imapwnd.cxx
+++ b/svx/source/dialog/imapwnd.cxx
@@ -652,7 +652,7 @@ void IMapWindow::DoMacroAssign()
         SvxMacroItem    aMacroItem(SID_ATTR_MACROITEM);
         IMapObject*     pIMapObj = GetIMapObj( pSdrObj );
         aMacroItem.SetMacroTable( pIMapObj->GetMacroTable() );
-        aSet.Put( aMacroItem, SID_ATTR_MACROITEM );
+        aSet.Put( aMacroItem );
 
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
         std::unique_ptr<SfxAbstractDialog> pMacroDlg(pFact->CreateSfxDialog( this, aSet, mxDocumentFrame, SID_EVENTCONFIG ));
diff --git a/svx/source/unodraw/UnoNameItemTable.cxx b/svx/source/unodraw/UnoNameItemTable.cxx
index 1ecba10..7107b9d 100644
--- a/svx/source/unodraw/UnoNameItemTable.cxx
+++ b/svx/source/unodraw/UnoNameItemTable.cxx
@@ -85,7 +85,8 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons
     std::unique_ptr<NameOrIndex> pNewItem(createItem());
     pNewItem->SetName( aName );
     pNewItem->PutValue( aElement, mnMemberId );
-    maItemSetVector.back()->Put( *pNewItem, mnWhich );
+    pNewItem->SetWhich(mnWhich);
+    maItemSetVector.back()->Put( *pNewItem );
 }
 
 // XNameContainer
diff --git a/svx/source/unodraw/unomtabl.cxx b/svx/source/unodraw/unomtabl.cxx
index dc2eb3c..5ed42a7 100644
--- a/svx/source/unodraw/unomtabl.cxx
+++ b/svx/source/unodraw/unomtabl.cxx
@@ -151,17 +151,17 @@ void SAL_CALL SvxUnoMarkerTable::ImplInsertByName( const OUString& aName, const
     SfxItemSet* pInSet = new SfxItemSet( *mpModelPool, XATTR_LINESTART, XATTR_LINEEND );
     maItemSetVector.push_back( pInSet );
 
-    XLineEndItem aEndMarker;
+    XLineEndItem aEndMarker(XATTR_LINEEND);
     aEndMarker.SetName( aName );
     aEndMarker.PutValue( aElement, 0 );
 
-    pInSet->Put( aEndMarker, XATTR_LINEEND );
+    pInSet->Put( aEndMarker );
 
-    XLineStartItem aStartMarker;
+    XLineStartItem aStartMarker(XATTR_LINESTART);
     aStartMarker.SetName( aName );
     aStartMarker.PutValue( aElement, 0 );
 
-    pInSet->Put( aStartMarker, XATTR_LINESTART );
+    pInSet->Put( aStartMarker );
 }
 
 // XNameContainer
@@ -228,18 +228,18 @@ void SAL_CALL SvxUnoMarkerTable::replaceByName( const OUString& aApiName, const
         const NameOrIndex *pItem = static_cast<const NameOrIndex *>(&((*aIter)->Get( XATTR_LINEEND ) ));
         if( pItem->GetName() == aName )
         {
-            XLineEndItem aEndMarker;
+            XLineEndItem aEndMarker(XATTR_LINEEND);
             aEndMarker.SetName( aName );
             if( !aEndMarker.PutValue( aElement, 0 ) )
                 throw lang::IllegalArgumentException();
 
-            (*aIter)->Put( aEndMarker, XATTR_LINEEND );
+            (*aIter)->Put( aEndMarker );
 
-            XLineStartItem aStartMarker;
+            XLineStartItem aStartMarker(XATTR_LINESTART);
             aStartMarker.SetName( aName );
             aStartMarker.PutValue( aElement, 0 );
 
-            (*aIter)->Put( aStartMarker, XATTR_LINESTART );
+            (*aIter)->Put( aStartMarker );
             return;
         }
         ++aIter;
diff --git a/sw/source/core/attr/swatrset.cxx b/sw/source/core/attr/swatrset.cxx
index 2f88ebf..2b8ab0f 100644
--- a/sw/source/core/attr/swatrset.cxx
+++ b/sw/source/core/attr/swatrset.cxx
@@ -178,7 +178,7 @@ SfxItemSet* SwAttrSet::Clone( bool bItems, SfxItemPool *pToPool ) const
                 {
                     const SfxPoolItem* pItem;
                     if ( SfxItemState::SET == GetItemState( nWhich, false, &pItem ) )
-                        pTmpSet->Put( *pItem, pItem->Which() );
+                        pTmpSet->Put( *pItem );
                     nWhich = aIter.NextWhich();
                 }
             }
diff --git a/sw/source/core/doc/poolfmt.cxx b/sw/source/core/doc/poolfmt.cxx
index 4c812b5..c780f81 100644
--- a/sw/source/core/doc/poolfmt.cxx
+++ b/sw/source/core/doc/poolfmt.cxx
@@ -102,9 +102,15 @@ void SetAllScriptItem( SfxItemSet& rSet, const SfxPoolItem& rItem )
     }
 
     if( nWhCJK )
-        rSet.Put( rItem, nWhCJK );
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(rItem.CloneSetWhich(nWhCJK));
+        rSet.Put( *pNewItem );
+    }
     if( nWhCTL )
-        rSet.Put( rItem, nWhCTL );
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(rItem.CloneSetWhich(nWhCTL));
+        rSet.Put( *pNewItem );
+    }
 }
 
 /// Return the AutoCollection by its Id. If it doesn't
diff --git a/sw/source/core/doc/tblafmt.cxx b/sw/source/core/doc/tblafmt.cxx
index c27194c..6c55d0b 100644
--- a/sw/source/core/doc/tblafmt.cxx
+++ b/sw/source/core/doc/tblafmt.cxx
@@ -779,9 +779,12 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
             }
             else
             {
-                rSet.Put( rChg.GetHeight(), RES_CHRATR_CJK_FONTSIZE );
-                rSet.Put( rChg.GetWeight(), RES_CHRATR_CJK_WEIGHT );
-                rSet.Put( rChg.GetPosture(), RES_CHRATR_CJK_POSTURE );
+                std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CJK_FONTSIZE));
+                rSet.Put( *pNewItem);
+                pNewItem.reset(rChg.GetWeight().CloneSetWhich(RES_CHRATR_CJK_WEIGHT));
+                rSet.Put( *pNewItem);
+                pNewItem.reset(rChg.GetPosture().CloneSetWhich(RES_CHRATR_CJK_POSTURE));
+                rSet.Put( *pNewItem);
             }
             // do not insert empty CTL font
             const SvxFontItem& rCTLFont = rChg.GetCTLFont();
@@ -794,9 +797,12 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
             }
             else
             {
-                rSet.Put( rChg.GetHeight(), RES_CHRATR_CTL_FONTSIZE );
-                rSet.Put( rChg.GetWeight(), RES_CHRATR_CTL_WEIGHT );
-                rSet.Put( rChg.GetPosture(), RES_CHRATR_CTL_POSTURE );
+                std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CTL_FONTSIZE));
+                rSet.Put( *pNewItem);
+                pNewItem.reset(rChg.GetWeight().CloneSetWhich(RES_CHRATR_CTL_WEIGHT));
+                rSet.Put( *pNewItem);
+                pNewItem.reset(rChg.GetPosture().CloneSetWhich(RES_CHRATR_CTL_POSTURE));
+                rSet.Put( *pNewItem);
             }
             rSet.Put( rChg.GetUnderline() );
             rSet.Put( rChg.GetOverline() );
diff --git a/sw/source/filter/ascii/parasc.cxx b/sw/source/filter/ascii/parasc.cxx
index 852b5b5..8857990 100644
--- a/sw/source/filter/ascii/parasc.cxx
+++ b/sw/source/filter/ascii/parasc.cxx
@@ -108,8 +108,10 @@ SwASCIIParser::SwASCIIParser(SwDoc* pD, const SwPaM& rCursor, SvStream& rIn,
         SvxLanguageItem aLang( (LanguageType)rOpt.GetLanguage(),
                                  RES_CHRATR_LANGUAGE );
         pItemSet->Put( aLang );
-        pItemSet->Put( aLang, RES_CHRATR_CJK_LANGUAGE );
-        pItemSet->Put( aLang, RES_CHRATR_CTL_LANGUAGE );
+        aLang.SetWhich(RES_CHRATR_CJK_LANGUAGE);
+        pItemSet->Put( aLang );
+        aLang.SetWhich(RES_CHRATR_CTL_LANGUAGE);
+        pItemSet->Put( aLang );
     }
     if( !rOpt.GetFontName().isEmpty() )
     {
@@ -119,8 +121,10 @@ SwASCIIParser::SwASCIIParser(SwDoc* pD, const SwPaM& rCursor, SvStream& rIn,
         SvxFontItem aFont( aTextFont.GetFamilyType(), aTextFont.GetFamilyName(),
                            OUString(), aTextFont.GetPitch(), aTextFont.GetCharSet(), RES_CHRATR_FONT );
         pItemSet->Put( aFont );
-        pItemSet->Put( aFont, RES_CHRATR_CJK_FONT );
-        pItemSet->Put( aFont, RES_CHRATR_CTL_FONT );
+        aFont.SetWhich(RES_CHRATR_CJK_FONT);
+        pItemSet->Put( aFont );
+        aFont.SetWhich(RES_CHRATR_CTL_FONT);
+        pItemSet->Put( aFont );
     }
 }
 
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index 0fe0bf5..37cb677 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -1864,7 +1864,7 @@ void SwWW8ImplReader::MatchSdrItemsIntoFlySet( SdrObject* pSdrObj,
     }
 
     if (bBrushItemOk)
-        rFlySet.Put(aBrushItem, RES_BACKGROUND);
+        rFlySet.Put(aBrushItem);
 }
 
 void SwWW8ImplReader::AdjustLRWrapForWordMargins(
diff --git a/sw/source/ui/dbui/dbinsdlg.cxx b/sw/source/ui/dbui/dbinsdlg.cxx
index c1babe1..f97036d 100644
--- a/sw/source/ui/dbui/dbinsdlg.cxx
+++ b/sw/source/ui/dbui/dbinsdlg.cxx
@@ -670,8 +670,10 @@ IMPL_LINK_TYPED( SwInsertDBColAutoPilot, TableFormatHdl, Button*, pButton, void
 
         SvxBrushItem aBrush( RES_BACKGROUND );
         pTableSet->Put( aBrush );
-        pTableSet->Put( aBrush, SID_ATTR_BRUSH_ROW );
-        pTableSet->Put( aBrush, SID_ATTR_BRUSH_TABLE );
+        aBrush.SetWhich(SID_ATTR_BRUSH_ROW);
+        pTableSet->Put( aBrush );
+        aBrush.SetWhich(SID_ATTR_BRUSH_TABLE);
+        pTableSet->Put( aBrush );
 
         SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
             // table variant, when multiple table cells are selected
diff --git a/sw/source/ui/frmdlg/wrap.cxx b/sw/source/ui/frmdlg/wrap.cxx
index e738e7c..d20fa3b 100644
--- a/sw/source/ui/frmdlg/wrap.cxx
+++ b/sw/source/ui/frmdlg/wrap.cxx
@@ -360,7 +360,7 @@ bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet)
         if(nullptr == (pOldItem = GetOldItem(*rSet, RES_UL_SPACE)) ||
                 aUL != *pOldItem )
         {
-            rSet->Put( aUL, RES_UL_SPACE );
+            rSet->Put( aUL );
             bModified = true;
         }
     }
@@ -377,7 +377,7 @@ bool SwWrapTabPage::FillItemSet(SfxItemSet *rSet)
         if( nullptr == (pOldItem = GetOldItem(*rSet, RES_LR_SPACE)) ||
                 aLR != *pOldItem )
         {
-            rSet->Put(aLR, RES_LR_SPACE);
+            rSet->Put(aLR);
             bModified = true;
         }
     }
diff --git a/sw/source/uibase/app/appopt.cxx b/sw/source/uibase/app/appopt.cxx
index f4f31a2..f1c01ee 100644
--- a/sw/source/uibase/app/appopt.cxx
+++ b/sw/source/uibase/app/appopt.cxx
@@ -136,14 +136,17 @@ SfxItemSet*  SwModule::CreateItemSet( sal_uInt16 nId )
             pRet->Put(SwPtrItem(FN_PARAM_PRINTER, pPrt));
         pRet->Put(SwPtrItem(FN_PARAM_WRTSHELL, &rWrtShell));
 
-        pRet->Put(static_cast<const SvxLanguageItem&>(
-            rWrtShell.GetDefault(RES_CHRATR_LANGUAGE)), SID_ATTR_LANGUAGE);
+        std::unique_ptr<SfxPoolItem> pNewItem( static_cast<const SvxLanguageItem&>(
+            rWrtShell.GetDefault(RES_CHRATR_LANGUAGE)).CloneSetWhich(SID_ATTR_LANGUAGE) );
+        pRet->Put(*pNewItem);
 
-        pRet->Put(static_cast<const SvxLanguageItem&>(
-            rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE)), SID_ATTR_CHAR_CJK_LANGUAGE);
+        pNewItem.reset(static_cast<const SvxLanguageItem&>(
+            rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE)).CloneSetWhich(SID_ATTR_CHAR_CJK_LANGUAGE));
+        pRet->Put(*pNewItem);
 
-        pRet->Put(static_cast<const SvxLanguageItem&>(
-            rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE)), SID_ATTR_CHAR_CTL_LANGUAGE);
+        pNewItem.reset(static_cast<const SvxLanguageItem&>(
+            rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE)).CloneSetWhich(SID_ATTR_CHAR_CTL_LANGUAGE));
+        pRet->Put(*pNewItem);
     }
     else
     {
diff --git a/sw/source/uibase/lingu/olmenu.cxx b/sw/source/uibase/lingu/olmenu.cxx
index 0eff29a..d4b1ace 100644
--- a/sw/source/uibase/lingu/olmenu.cxx
+++ b/sw/source/uibase/lingu/olmenu.cxx
@@ -616,7 +616,7 @@ void SwSpellPopup::checkRedline()
     SfxItemSet aSet(pDoc->GetAttrPool(), FN_REDLINE_ACCEPT_DIRECT, FN_REDLINE_PREV_CHANGE);
     for (sal_uInt16 nWhich : pRedlineIds)
     {
-        aSet.Put(SfxVoidItem(nWhich), nWhich);
+        aSet.Put(SfxVoidItem(nWhich));
     }
     m_pSh->GetView().GetState(aSet);
 
diff --git a/sw/source/uibase/shells/annotsh.cxx b/sw/source/uibase/shells/annotsh.cxx
index c156d6e..d9b8d9f 100644
--- a/sw/source/uibase/shells/annotsh.cxx
+++ b/sw/source/uibase/shells/annotsh.cxx
@@ -366,7 +366,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
             else
                 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
-            aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
+            aNewAttr.Put( aItem );
         }
         break;
         case FN_SET_SUB_SCRIPT:
@@ -379,7 +379,7 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
             else
                 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
-            aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
+            aNewAttr.Put( aItem );
         }
         break;
         case SID_HYPERLINK_SETLINK:
@@ -603,7 +603,10 @@ void SwAnnotationShell::Exec( SfxRequest &rReq )
     }
 
     if(nEEWhich && pNewAttrs)
-        aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich));
+        aNewAttr.Put(*pNewItem);
+    }
 
     Rectangle aNullRect;
     Rectangle aOutRect = pOLV->GetOutputArea();
@@ -702,7 +705,10 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet)
                     aSetItem.GetItemSet().Put( aEditAttr, false );
                     const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
                     if( pI )
-                        rSet.Put( *pI, nWhich );
+                    {
+                        std::unique_ptr<SfxPoolItem> pNewItem(pI->CloneSetWhich(nWhich));
+                        rSet.Put( *pNewItem );
+                    }
                     else
                         rSet.InvalidateItem( nWhich );
                 }
@@ -851,16 +857,17 @@ void SwAnnotationShell::GetState(SfxItemSet& rSet)
 
         if(nEEWhich)
         {
-            rSet.Put(aEditAttr.Get(nEEWhich), nWhich);
-        if(nEEWhich == EE_CHAR_KERNING)
-        {
-            SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING );
-            if ( eState == SfxItemState::DONTCARE )
+            std::unique_ptr<SfxPoolItem> pNewItem(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich));
+            rSet.Put(*pNewItem);
+            if(nEEWhich == EE_CHAR_KERNING)
             {
-                rSet.InvalidateItem(EE_CHAR_KERNING);
+                SfxItemState eState = aEditAttr.GetItemState( EE_CHAR_KERNING );
+                if ( eState == SfxItemState::DONTCARE )
+                {
+                    rSet.InvalidateItem(EE_CHAR_KERNING);
+                }
             }
         }
-        }
 
         if (pPostItMgr->GetActiveSidebarWin()->GetLayoutStatus()==SwPostItHelper::DELETED)
             rSet.DisableItem( nWhich );
@@ -1774,11 +1781,17 @@ void SwAnnotationShell::InsertSymbol(SfxRequest& rReq)
                                 EE_CHAR_FONTINFO );
         SvtScriptType nScriptBreak = g_pBreakIt->GetAllScriptsOfText( sSym );
         if( SvtScriptType::LATIN & nScriptBreak )
-            aSetFont.Put( aFontItem, EE_CHAR_FONTINFO );
+            aSetFont.Put( aFontItem );
         if( SvtScriptType::ASIAN & nScriptBreak )
-            aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
+        {
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK);
+            aSetFont.Put( aFontItem );
+        }
         if( SvtScriptType::COMPLEX & nScriptBreak )
-            aSetFont.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
+        {
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL);
+            aSetFont.Put( aFontItem );
+        }
         pOLV->SetAttribs(aSetFont);
 
         // Erase selection
diff --git a/sw/source/uibase/shells/basesh.cxx b/sw/source/uibase/shells/basesh.cxx
index 03572fcc..eb70ed6 100644
--- a/sw/source/uibase/shells/basesh.cxx
+++ b/sw/source/uibase/shells/basesh.cxx
@@ -2117,7 +2117,10 @@ void SwBaseShell::GetTextFontCtrlState( SfxItemSet& rSet )
                 aSetItem.GetItemSet().Put( *pFntCoreSet, false );
                 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
                 if( pI )
-                    rSet.Put( *pI, nWhich );
+                {
+                    std::unique_ptr<SfxPoolItem> pNewItem(pI->CloneSetWhich(nWhich));
+                    rSet.Put( *pNewItem );
+                }
                 else
                     rSet.InvalidateItem( nWhich );
                 // Set input context of the SwEditWin according to the selected font and script type
@@ -2191,13 +2194,14 @@ void SwBaseShell::GetBckColState(SfxItemSet &rSet)
             case SID_BACKGROUND_COLOR:
             {
                 SvxColorItem aColorItem(aBrushItem.GetColor(),SID_BACKGROUND_COLOR);
-                rSet.Put(aColorItem,SID_BACKGROUND_COLOR);
+                rSet.Put(aColorItem);
                 break;
             }
             case SID_ATTR_BRUSH:
             case RES_BACKGROUND:
             {
-                rSet.Put(aBrushItem,GetPool().GetWhich(nWhich));
+                std::unique_ptr<SfxPoolItem> pNewItem(aBrushItem.CloneSetWhich(GetPool().GetWhich(nWhich)));
+                rSet.Put(*pNewItem);
                 break;
             }
         }
diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx
index 4bbd6a9..0943a1f 100644
--- a/sw/source/uibase/shells/drwtxtex.cxx
+++ b/sw/source/uibase/shells/drwtxtex.cxx
@@ -297,7 +297,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
             else
                 aItem.SetEscapement( SVX_ESCAPEMENT_SUPERSCRIPT );
-            aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
+            aNewAttr.Put( aItem );
         }
         break;
         case FN_SET_SUB_SCRIPT:
@@ -310,7 +310,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
                 aItem.SetEscapement( SVX_ESCAPEMENT_OFF );
             else
                 aItem.SetEscapement( SVX_ESCAPEMENT_SUBSCRIPT );
-            aNewAttr.Put( aItem, EE_CHAR_ESCAPEMENT );
+            aNewAttr.Put( aItem );
         }
         break;
 
@@ -564,7 +564,10 @@ void SwDrawTextShell::Execute( SfxRequest &rReq )
             return;
     }
     if(nEEWhich && pNewAttrs)
-        aNewAttr.Put(pNewAttrs->Get(nWhich), nEEWhich);
+    {
+        std::unique_ptr<SfxPoolItem> pNewItem(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich));
+        aNewAttr.Put(*pNewItem);
+    }
 
     SetAttrToMarked(aNewAttr);
 
@@ -891,7 +894,10 @@ void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet)
                 aSetItem.GetItemSet().Put( aEditAttr, false );
                 const SfxPoolItem* pI = aSetItem.GetItemOfScript( nScriptType );
                 if( pI )
-                    rSet.Put( *pI, nWhich );
+                {
+                    std::unique_ptr<SfxPoolItem> pNewItem(pI->CloneSetWhich(nWhich));
+                    rSet.Put( *pNewItem );
+                }
                 else
                     rSet.InvalidateItem( nWhich );
             }
@@ -941,7 +947,10 @@ void SwDrawTextShell::GetDrawTextCtrlState(SfxItemSet& rSet)
             }
         }
         if(nEEWhich)
-            rSet.Put(aEditAttr.Get(nEEWhich), nWhich);
+        {
+            std::unique_ptr<SfxPoolItem> pNewItem(aEditAttr.Get(nEEWhich).CloneSetWhich(nWhich));
+            rSet.Put(*pNewItem);
+        }
 
         nWhich = aIter.NextWhich();
     }
diff --git a/sw/source/uibase/shells/drwtxtsh.cxx b/sw/source/uibase/shells/drwtxtsh.cxx
index 15fb8fb..df2dbda 100644
--- a/sw/source/uibase/shells/drwtxtsh.cxx
+++ b/sw/source/uibase/shells/drwtxtsh.cxx
@@ -792,11 +792,17 @@ void SwDrawTextShell::InsertSymbol(SfxRequest& rReq)
                                 EE_CHAR_FONTINFO );
         nScript = g_pBreakIt->GetAllScriptsOfText( sSym );
         if( SvtScriptType::LATIN & nScript )
-            aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO );
+            aFontAttribSet.Put( aFontItem );
         if( SvtScriptType::ASIAN & nScript )
-            aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CJK );
+        {
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CJK);
+            aFontAttribSet.Put( aFontItem );
+        }
         if( SvtScriptType::COMPLEX & nScript )
-            aFontAttribSet.Put( aFontItem, EE_CHAR_FONTINFO_CTL );
+        {
+            aFontItem.SetWhich(EE_CHAR_FONTINFO_CTL);
+            aFontAttribSet.Put( aFontItem );
+        }
         pOLV->SetAttribs(aFontAttribSet);
 
         // Remove selection
diff --git a/sw/source/uibase/shells/langhelper.cxx b/sw/source/uibase/shells/langhelper.cxx
index bc9aa32..2a328ab 100644
--- a/sw/source/uibase/shells/langhelper.cxx
+++ b/sw/source/uibase/shells/langhelper.cxx
@@ -96,7 +96,7 @@ namespace SwLangHelper
         // set sequence as status value
         SfxStringListItem aItem( SID_LANGUAGE_STATUS );
         aItem.SetStringList( aSeq );
-        rSet.Put( aItem, SID_LANGUAGE_STATUS );
+        rSet.Put( aItem );
         return 0;
     }
 
diff --git a/sw/source/uibase/shells/tabsh.cxx b/sw/source/uibase/shells/tabsh.cxx
index ef4d98a..ac84b52 100644
--- a/sw/source/uibase/shells/tabsh.cxx
+++ b/sw/source/uibase/shells/tabsh.cxx
@@ -159,16 +159,23 @@ static SwTableRep*  lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
     rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
     SvxBrushItem aBrush( RES_BACKGROUND );
     if(rSh.GetRowBackground(aBrush))
-        rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
+    {
+        aBrush.SetWhich(SID_ATTR_BRUSH_ROW);
+        rSet.Put( aBrush );
+    }
     else
         rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
     rSh.GetTabBackground(aBrush);
-    rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
+    aBrush.SetWhich(SID_ATTR_BRUSH_TABLE);
+    rSet.Put( aBrush );
 
     // text direction in boxes
     SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
     if(rSh.GetBoxDirection( aBoxDirection ))
-        rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION);
+    {
+        aBoxDirection.SetWhich(FN_TABLE_BOX_TEXTORIENTATION);
+        rSet.Put(aBoxDirection);
+    }
 
     bool bSelectAll = rSh.StartsWithTable() && rSh.ExtendedSelectedAll();
     bool bTableSel = rSh.IsTableMode() || bSelectAll;
diff --git a/sw/source/uibase/shells/textsh.cxx b/sw/source/uibase/shells/textsh.cxx
index fe8b827..392e42c 100644
--- a/sw/source/uibase/shells/textsh.cxx
+++ b/sw/source/uibase/shells/textsh.cxx
@@ -1006,17 +1006,20 @@ void SwTextShell::InsertSymbol( SfxRequest& rReq )
             if( SvtScriptType::LATIN & nScript )
             {
                 aRestoreSet.Put( aSet.Get( RES_CHRATR_FONT ) );
-                aSet.Put( aNewFontItem, RES_CHRATR_FONT);
+                aNewFontItem.SetWhich(RES_CHRATR_FONT);
+                aSet.Put( aNewFontItem );
             }
             if( SvtScriptType::ASIAN & nScript )
             {
                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CJK_FONT ) );
-                aSet.Put( aNewFontItem, RES_CHRATR_CJK_FONT );
+                aNewFontItem.SetWhich(RES_CHRATR_CJK_FONT);
+                aSet.Put( aNewFontItem );
             }
             if( SvtScriptType::COMPLEX & nScript )
             {
                 aRestoreSet.Put( aSet.Get( RES_CHRATR_CTL_FONT ) );
-                aSet.Put( aNewFontItem, RES_CHRATR_CTL_FONT );
+                aNewFontItem.SetWhich(RES_CHRATR_CTL_FONT);
+                aSet.Put( aNewFontItem );
             }
 
             rSh.SetMark();
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index c56621e..6e7d164 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1457,7 +1457,7 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                 // set sequence as status value
                 SfxStringListItem aItem( SID_LANGUAGE_STATUS );
                 aItem.SetStringList( aSeq );
-                rSet.Put( aItem, SID_LANGUAGE_STATUS );
+                rSet.Put( aItem );
             }
         break;
 
@@ -1615,7 +1615,8 @@ void SwTextShell::GetState( SfxItemSet &rSet )
                 SfxItemSet aSet( GetPool() );
                 rSh.GetCurAttr( aSet );
                 const SvxColorItem& aColorItem = static_cast< const SvxColorItem& >( aSet.Get(RES_CHRATR_COLOR) );
-                rSet.Put( aColorItem, SID_ATTR_CHAR_COLOR2 );
+                std::unique_ptr<SfxPoolItem> pNewItem(aColorItem.CloneSetWhich(SID_ATTR_CHAR_COLOR2));
+                rSet.Put( *pNewItem );
             }
             break;
         case SID_ATTR_CHAR_COLOR_BACKGROUND:
diff --git a/sw/source/uibase/uiview/formatclipboard.cxx b/sw/source/uibase/uiview/formatclipboard.cxx
index 8ded862..cab5e7b 100644
--- a/sw/source/uibase/uiview/formatclipboard.cxx
+++ b/sw/source/uibase/uiview/formatclipboard.cxx
@@ -92,11 +92,15 @@ void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
      rSh.GetBoxBackground(aBrush);
     rSet.Put( aBrush );
     if(rSh.GetRowBackground(aBrush))
-        rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
+    {
+        aBrush.SetWhich(SID_ATTR_BRUSH_ROW);
+        rSet.Put( aBrush );
+    }
     else
         rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
     rSh.GetTabBackground(aBrush);
-    rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
+    aBrush.SetWhich(SID_ATTR_BRUSH_TABLE);
+    rSet.Put( aBrush );
 
     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     rSet.Put(aBoxInfo);
@@ -104,7 +108,10 @@ void lcl_getTableAttributes( SfxItemSet& rSet, SwWrtShell &rSh )
 
     SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
     if(rSh.GetBoxDirection( aBoxDirection ))
-        rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION);
+    {
+        aBoxDirection.SetWhich(FN_TABLE_BOX_TEXTORIENTATION);
+        rSet.Put(aBoxDirection);
+    }
 
     rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
 
diff --git a/sw/source/uibase/uiview/viewstat.cxx b/sw/source/uibase/uiview/viewstat.cxx
index ecb2302..5723088 100644
--- a/sw/source/uibase/uiview/viewstat.cxx
+++ b/sw/source/uibase/uiview/viewstat.cxx
@@ -237,17 +237,24 @@ void SwView::GetState(SfxItemSet &rSet)
             break;
             case SID_ATTR_LANGUAGE:
             {
-                rSet.Put(static_cast<const SvxLanguageItem&>(
-                    m_pWrtShell->GetDefault(RES_CHRATR_LANGUAGE)), SID_ATTR_LANGUAGE);
+                std::unique_ptr<SfxPoolItem> pNewItem(static_cast<const SvxLanguageItem&>(
+                    m_pWrtShell->GetDefault(RES_CHRATR_LANGUAGE)).CloneSetWhich(SID_ATTR_LANGUAGE));
+                rSet.Put(*pNewItem);
             }
             break;
             case RES_CHRATR_CJK_LANGUAGE:
-                rSet.Put(static_cast<const SvxLanguageItem&>(
-                    m_pWrtShell->GetDefault(RES_CHRATR_CJK_LANGUAGE)), RES_CHRATR_CJK_LANGUAGE);
+            {
+                std::unique_ptr<SfxPoolItem> pNewItem(static_cast<const SvxLanguageItem&>(
+                    m_pWrtShell->GetDefault(RES_CHRATR_CJK_LANGUAGE)).CloneSetWhich(RES_CHRATR_CJK_LANGUAGE));
+                rSet.Put(*pNewItem);
+            }
             break;
             case RES_CHRATR_CTL_LANGUAGE:
-                rSet.Put(static_cast<const SvxLanguageItem&>(
-                    m_pWrtShell->GetDefault(RES_CHRATR_CTL_LANGUAGE)), RES_CHRATR_CTL_LANGUAGE);
+            {
+                std::unique_ptr<SfxPoolItem> pNewItem(static_cast<const SvxLanguageItem&>(
+                    m_pWrtShell->GetDefault(RES_CHRATR_CTL_LANGUAGE)).CloneSetWhich(RES_CHRATR_CTL_LANGUAGE));
+                rSet.Put(*pNewItem);
+            }
             break;
             case FN_REDLINE_ON:
                 rSet.Put( SfxBoolItem( nWhich, GetDocShell()->IsChangeRecording() ) );
@@ -449,7 +456,10 @@ void SwView::GetState(SfxItemSet &rSet)
                 if(nAlias)
                     GetViewFrame()->GetDispatcher()->QueryState( nAlias, pState );
                 if(pState)
-                    rSet.Put(*pState, nWhich);
+                {
+                    std::unique_ptr<SfxPoolItem> pNewItem(pState->CloneSetWhich(nWhich));
+                    rSet.Put(*pNewItem);
+                }
                 else if(!bDraw)
                     rSet.DisableItem(nWhich);
             }
diff --git a/sw/source/uibase/uiview/viewtab.cxx b/sw/source/uibase/uiview/viewtab.cxx
index b4d865c..7ab973d 100644
--- a/sw/source/uibase/uiview/viewtab.cxx
+++ b/sw/source/uibase/uiview/viewtab.cxx
@@ -1239,7 +1239,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                 m_pHRuler->SetDefTabDist( nDefTabDist );
                 m_pVRuler->SetDefTabDist( nDefTabDist );
                 ::lcl_EraseDefTabs(aTabStops);
-                rSet.Put(aTabStops, nWhich);
+                aTabStops.SetWhich(nWhich);
+                rSet.Put(aTabStops);
             }
             break;
         }
@@ -1535,7 +1536,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                                 0, 0, true);
                     aColItem.Append(aColDesc);
                 }
-                rSet.Put(aColItem, nWhich);
+                aColItem.SetWhich(nWhich);
+                rSet.Put(aColItem);
             }
             else if ( bFrameSelection || nFrameType & ( FrameTypeFlags::COLUMN | FrameTypeFlags::COLSECT ) )
             {
@@ -1589,7 +1591,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                         }
                         aColItem.SetOrtho(aColItem.CalcOrtho());
 
-                        rSet.Put(aColItem, nWhich);
+                        aColItem.SetWhich(nWhich);
+                        rSet.Put(aColItem);
                     }
                 }
                 else if( bFrameSelection || nFrameType & FrameTypeFlags::FLY_ANY )
@@ -1629,7 +1632,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
 
                         aColItem.SetOrtho(aColItem.CalcOrtho());
 
-                        rSet.Put(aColItem, nWhich);
+                        aColItem.SetWhich(nWhich);
+                        rSet.Put(aColItem);
                     }
                     else
                         rSet.DisableItem(nWhich);
@@ -1682,7 +1686,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                     }
                     aColItem.SetOrtho(aColItem.CalcOrtho());
 
-                    rSet.Put(aColItem, nWhich);
+                    aColItem.SetWhich(nWhich);
+                    rSet.Put(aColItem);
                 }
             }
             else
@@ -1770,7 +1775,8 @@ void SwView::StateTabWin(SfxItemSet& rSet)
                                             false );
                 aColItem.Append(aColDesc);
 
-                rSet.Put(aColItem, nWhich);
+                aColItem.SetWhich(nWhich);
+                rSet.Put(aColItem);
             }
             else
                 rSet.DisableItem(nWhich);


More information about the Libreoffice-commits mailing list