Kaydet (Commit) d4dff7dc authored tarafından Noel Grandin's avatar Noel Grandin

return std::unique_ptr from CloneSetWhich

Change-Id: I709122cb8cd7c257e7eb2bd564c529689e6d555a
Reviewed-on: https://gerrit.libreoffice.org/62350
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst dd16804e
...@@ -173,10 +173,10 @@ public: ...@@ -173,10 +173,10 @@ public:
virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const; virtual SvStream& Store( SvStream &, sal_uInt16 nItemVersion ) const;
virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0; virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0;
// clone and call SetWhich // clone and call SetWhich
SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const; std::unique_ptr<SfxPoolItem> CloneSetWhich( sal_uInt16 nNewWhich ) const;
template<class T> T* CloneSetWhich( TypedWhichId<T> nId ) const template<class T> std::unique_ptr<T> CloneSetWhich( TypedWhichId<T> nId ) const
{ {
return static_cast<T*>(CloneSetWhich(sal_uInt16(nId))); return std::unique_ptr<T>(static_cast<T*>(CloneSetWhich(sal_uInt16(nId)).release()));
} }
sal_uInt32 GetRefCount() const { return m_nRefCount; } sal_uInt32 GetRefCount() const { return m_nRefCount; }
......
...@@ -392,9 +392,9 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const ...@@ -392,9 +392,9 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const
// FillToEditItemSet() adjusts font height to 1/100th mm, we need twips // FillToEditItemSet() adjusts font height to 1/100th mm, we need twips
std::unique_ptr<SfxPoolItem> pNewItem( aItemSet.Get( ATTR_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT)); std::unique_ptr<SfxPoolItem> pNewItem( aItemSet.Get( ATTR_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT));
pEditSet->Put( *pNewItem ); pEditSet->Put( *pNewItem );
pNewItem.reset( aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); pNewItem = aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK);
pEditSet->Put( *pNewItem ); pEditSet->Put( *pNewItem );
pNewItem.reset( aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); pNewItem = aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL);
pEditSet->Put( *pNewItem ); pEditSet->Put( *pNewItem );
rEE.SetDefaults( pEditSet ); // takes ownership rEE.SetDefaults( pEditSet ); // takes ownership
} }
......
...@@ -1139,9 +1139,9 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() ...@@ -1139,9 +1139,9 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder()
// but for header/footer twips is needed, as in the PatternAttr: // but for header/footer twips is needed, as in the PatternAttr:
std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT)); std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK);
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL);
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) );
pHdrEngine->SetDefaults( aDefaults ); pHdrEngine->SetDefaults( aDefaults );
......
...@@ -163,9 +163,9 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern ) ...@@ -163,9 +163,9 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern )
// but for header/footer twips is needed, as in the PatternAttr: // but for header/footer twips is needed, as in the PatternAttr:
std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT)); std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
pSet->Put( *pNewItem ); pSet->Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK);
pSet->Put( *pNewItem ); pSet->Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL);
pSet->Put( *pNewItem ); pSet->Put( *pNewItem );
if (mbRTL) if (mbRTL)
pSet->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) ); pSet->Put( SvxAdjustItem( SvxAdjust::Right, EE_PARA_JUST ) );
......
...@@ -221,9 +221,9 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder() ...@@ -221,9 +221,9 @@ SvxTextForwarder* ScHeaderFooterTextData::GetTextForwarder()
// but for header/footer twips is needed, as in the PatternAttr: // but for header/footer twips is needed, as in the PatternAttr:
std::unique_ptr<SfxPoolItem> pNewItem( rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) ); std::unique_ptr<SfxPoolItem> pNewItem( rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT) );
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
pNewItem.reset( rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK) ); pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK);
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
pNewItem.reset( rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL) ); pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL);
aDefaults.Put( *pNewItem ); aDefaults.Put( *pNewItem );
pHdrEngine->SetDefaults( aDefaults ); pHdrEngine->SetDefaults( aDefaults );
......
...@@ -1726,9 +1726,9 @@ void ScPrintFunc::MakeEditEngine() ...@@ -1726,9 +1726,9 @@ void ScPrintFunc::MakeEditEngine()
// but for header/footer twips is needed, as in the PatternAttr: // but for header/footer twips is needed, as in the PatternAttr:
std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT)); std::unique_ptr<SfxPoolItem> pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT));
pEditDefaults->Put( *pNewItem ); pEditDefaults->Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK);
pEditDefaults->Put( *pNewItem ); pEditDefaults->Put( *pNewItem );
pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL);
pEditDefaults->Put( *pNewItem ); pEditDefaults->Put( *pNewItem );
// don't use font color, because background color is not used // don't use font color, because background color is not used
//! there's no way to set the background for note pages //! there's no way to set the background for note pages
......
...@@ -127,11 +127,11 @@ void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const ...@@ -127,11 +127,11 @@ void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter); xmlTextWriterEndElement(pWriter);
} }
SfxPoolItem* SfxPoolItem::CloneSetWhich( sal_uInt16 nNewWhich ) const std::unique_ptr<SfxPoolItem> SfxPoolItem::CloneSetWhich( sal_uInt16 nNewWhich ) const
{ {
SfxPoolItem* pItem = Clone(); SfxPoolItem* pItem = Clone();
pItem->SetWhich(nNewWhich); pItem->SetWhich(nNewWhich);
return pItem; return std::unique_ptr<SfxPoolItem>(pItem);
} }
bool SfxPoolItem::IsVoidItem() const bool SfxPoolItem::IsVoidItem() const
......
...@@ -817,9 +817,9 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet, ...@@ -817,9 +817,9 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
{ {
std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CJK_FONTSIZE)); std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CJK_FONTSIZE));
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
pNewItem.reset(rChg.GetWeight().CloneSetWhich(RES_CHRATR_CJK_WEIGHT)); pNewItem = rChg.GetWeight().CloneSetWhich(RES_CHRATR_CJK_WEIGHT);
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
pNewItem.reset(rChg.GetPosture().CloneSetWhich(RES_CHRATR_CJK_POSTURE)); pNewItem = rChg.GetPosture().CloneSetWhich(RES_CHRATR_CJK_POSTURE);
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
} }
// do not insert empty CTL font // do not insert empty CTL font
...@@ -835,9 +835,9 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet, ...@@ -835,9 +835,9 @@ void SwTableAutoFormat::UpdateToSet(sal_uInt8 nPos, SfxItemSet& rSet,
{ {
std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CTL_FONTSIZE)); std::unique_ptr<SfxPoolItem> pNewItem(rChg.GetHeight().CloneSetWhich(RES_CHRATR_CTL_FONTSIZE));
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
pNewItem.reset(rChg.GetWeight().CloneSetWhich(RES_CHRATR_CTL_WEIGHT)); pNewItem = rChg.GetWeight().CloneSetWhich(RES_CHRATR_CTL_WEIGHT);
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
pNewItem.reset(rChg.GetPosture().CloneSetWhich(RES_CHRATR_CTL_POSTURE)); pNewItem = rChg.GetPosture().CloneSetWhich(RES_CHRATR_CTL_POSTURE);
rSet.Put( *pNewItem); rSet.Put( *pNewItem);
} }
rSet.Put( rChg.GetUnderline() ); rSet.Put( rChg.GetUnderline() );
......
...@@ -138,12 +138,10 @@ std::unique_ptr<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId ) ...@@ -138,12 +138,10 @@ std::unique_ptr<SfxItemSet> SwModule::CreateItemSet( sal_uInt16 nId )
rWrtShell.GetDefault(RES_CHRATR_LANGUAGE).CloneSetWhich(SID_ATTR_LANGUAGE) ); rWrtShell.GetDefault(RES_CHRATR_LANGUAGE).CloneSetWhich(SID_ATTR_LANGUAGE) );
pRet->Put(*pNewItem); pRet->Put(*pNewItem);
pNewItem.reset( pNewItem = rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CJK_LANGUAGE);
rWrtShell.GetDefault(RES_CHRATR_CJK_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CJK_LANGUAGE));
pRet->Put(*pNewItem); pRet->Put(*pNewItem);
pNewItem.reset( pNewItem = rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CTL_LANGUAGE);
rWrtShell.GetDefault(RES_CHRATR_CTL_LANGUAGE).CloneSetWhich(SID_ATTR_CHAR_CTL_LANGUAGE));
pRet->Put(*pNewItem); pRet->Put(*pNewItem);
} }
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment