use unique_ptr when Clone()'ing PoolItems
and fix a handful of small leaks in the process Change-Id: I876e12ff5305f9dda84532d4182fb91657d6fa0c Reviewed-on: https://gerrit.libreoffice.org/62389 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
@@ -97,28 +97,22 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const
|
||||
if( GetItemProperty( nWhich, aProperty ))
|
||||
{
|
||||
// put the Property into the itemset
|
||||
SfxPoolItem * pItem = rPool.GetDefaultItem( nWhich ).Clone();
|
||||
std::unique_ptr<SfxPoolItem> pItem(rPool.GetDefaultItem( nWhich ).Clone());
|
||||
|
||||
if( pItem )
|
||||
{
|
||||
try
|
||||
{
|
||||
if( ! pItem->PutValue( m_xPropertySet->getPropertyValue( aProperty.first ),
|
||||
if( pItem->PutValue( m_xPropertySet->getPropertyValue( aProperty.first ),
|
||||
aProperty.second // nMemberId
|
||||
))
|
||||
{
|
||||
delete pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->SetWhich(nWhich);
|
||||
rOutItemSet.Put( *pItem );
|
||||
delete pItem;
|
||||
}
|
||||
}
|
||||
catch( const beans::UnknownPropertyException &ex )
|
||||
{
|
||||
delete pItem;
|
||||
SAL_WARN( "chart2", ex << " - unknown Property: " << aProperty.first);
|
||||
}
|
||||
catch( const uno::Exception & )
|
||||
|
||||
@@ -1238,9 +1238,8 @@ std::unique_ptr<SfxItemSet> OfaTreeOptionsDialog::CreateItemSet( sal_uInt16 nId
|
||||
pRet->Put(aHyphen);
|
||||
if(SfxItemState::DEFAULT <= pDispatch->QueryState(SID_AUTOSPELL_CHECK, pItem))
|
||||
{
|
||||
SfxPoolItem* pClone = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pClone(pItem->Clone());
|
||||
pRet->Put(*pClone);
|
||||
delete pClone;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -896,11 +896,10 @@ void ConvertAndPutItems( SfxItemSet& rDest, const SfxItemSet& rSource, const Map
|
||||
MapUnit eDestUnit = pDestUnit ? *pDestUnit : pDestPool->GetMetric( nWhich );
|
||||
if ( eSourceUnit != eDestUnit )
|
||||
{
|
||||
SfxPoolItem* pItem = rSource.Get( nSourceWhich ).Clone();
|
||||
std::unique_ptr<SfxPoolItem> pItem(rSource.Get( nSourceWhich ).Clone());
|
||||
ConvertItem( *pItem, eSourceUnit, eDestUnit );
|
||||
pItem->SetWhich(nWhich);
|
||||
rDest.Put( *pItem );
|
||||
delete pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1237,10 +1237,9 @@ EditSelection ImpEditEngine::InsertTextObject( const EditTextObject& rTextObject
|
||||
pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *(rX.GetItem()), rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos );
|
||||
else
|
||||
{
|
||||
SfxPoolItem* pNew = rX.GetItem()->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNew(rX.GetItem()->Clone());
|
||||
ConvertItem( *pNew, eSourceUnit, eDestUnit );
|
||||
pAttr = MakeCharAttrib( aEditDoc.GetItemPool(), *pNew, rX.GetStart()+nStartPos, rX.GetEnd()+nStartPos );
|
||||
delete pNew;
|
||||
}
|
||||
DBG_ASSERT( pAttr->GetEnd() <= aPaM.GetNode()->Len(), "InsertBinTextObject: Attribute does not fit! (1)" );
|
||||
aPaM.GetNode()->GetCharAttribs().InsertAttrib( pAttr );
|
||||
|
||||
@@ -171,7 +171,7 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa
|
||||
SvxUnoConvertFromMM( eMapUnit, aValue );
|
||||
}
|
||||
|
||||
SfxPoolItem *pNewItem = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem( pItem->Clone() );
|
||||
|
||||
sal_uInt8 nMemberId = pMap->nMemberId;
|
||||
if( eMapUnit == MapUnit::Map100thMM )
|
||||
@@ -183,7 +183,6 @@ void SvxItemPropertySet::setPropertyValue( const SfxItemPropertySimpleEntry* pMa
|
||||
pNewItem->SetWhich( pMap->nWID );
|
||||
rSet.Put( *pNewItem );
|
||||
}
|
||||
delete pNewItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -225,10 +225,9 @@ namespace frm
|
||||
WhichId nNormalizedWhichId = _rScriptSetItem.GetItemSet().GetPool()->GetWhich( _rScriptSetItem.Which() );
|
||||
if ( pNormalizedItem )
|
||||
{
|
||||
SfxPoolItem* pProperWhich = pNormalizedItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pProperWhich(pNormalizedItem->Clone());
|
||||
pProperWhich->SetWhich( nNormalizedWhichId );
|
||||
_rScriptSetItem.GetItemSet().Put( *pProperWhich );
|
||||
DELETEZ( pProperWhich );
|
||||
}
|
||||
else
|
||||
_rScriptSetItem.GetItemSet().InvalidateItem( nNormalizedWhichId );
|
||||
|
||||
@@ -281,7 +281,7 @@ namespace frm
|
||||
|
||||
const SfxPoolItem* pItem = _rAttribs.GetItem( getWhich() );
|
||||
if ( pItem )
|
||||
aState.setItem( pItem->Clone() );
|
||||
aState.setItem( pItem );
|
||||
|
||||
return aState;
|
||||
}
|
||||
@@ -291,14 +291,13 @@ namespace frm
|
||||
{
|
||||
if ( _pAdditionalArg )
|
||||
{
|
||||
SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCorrectWich(_pAdditionalArg->Clone());
|
||||
pCorrectWich->SetWhich( getWhich() );
|
||||
|
||||
if ( m_bScriptDependent )
|
||||
putItemForScript( _rNewAttribs, *pCorrectWich, _nForScriptType );
|
||||
else
|
||||
_rNewAttribs.Put( *pCorrectWich );
|
||||
DELETEZ( pCorrectWich );
|
||||
}
|
||||
else
|
||||
OSL_FAIL( "SlotHandler::executeAttribute: need attributes to do something!" );
|
||||
@@ -434,10 +433,9 @@ namespace frm
|
||||
OSL_ENSURE( dynamic_cast<const SfxBoolItem*>( _pAdditionalArg) != nullptr, "BooleanHandler::executeAttribute: invalid argument!" );
|
||||
if ( _pAdditionalArg )
|
||||
{
|
||||
SfxPoolItem* pCorrectWich = _pAdditionalArg->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCorrectWich(_pAdditionalArg->Clone());
|
||||
pCorrectWich->SetWhich( getWhich() );
|
||||
_rNewAttribs.Put( *pCorrectWich );
|
||||
DELETEZ( pCorrectWich );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -746,9 +746,9 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
|
||||
SCROW nY1 = nStart;
|
||||
SCROW nY2 = mvData[nPos].nEndRow;
|
||||
|
||||
SvxBoxItem* pNewBoxItem = pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr;
|
||||
SvxLineItem* pNewTLBRItem = pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr;
|
||||
SvxLineItem* pNewBLTRItem = pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr;
|
||||
std::unique_ptr<SvxBoxItem> pNewBoxItem( pBoxItem ? static_cast<SvxBoxItem*>(pBoxItem->Clone()) : nullptr);
|
||||
std::unique_ptr<SvxLineItem> pNewTLBRItem( pTLBRItem ? static_cast<SvxLineItem*>(pTLBRItem->Clone()) : nullptr);
|
||||
std::unique_ptr<SvxLineItem> pNewBLTRItem(pBLTRItem ? static_cast<SvxLineItem*>(pBLTRItem->Clone()) : nullptr);
|
||||
|
||||
// fetch line and update attributes with parameters
|
||||
|
||||
@@ -823,9 +823,6 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow,
|
||||
else
|
||||
nPos++;
|
||||
}
|
||||
delete pNewBoxItem;
|
||||
delete pNewTLBRItem;
|
||||
delete pNewBLTRItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -659,11 +659,10 @@ void SAL_CALL ScAutoFormatFieldObj::setPropertyValue(
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SfxPoolItem* pNewItem = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
|
||||
bDone = pNewItem->PutValue( aValue, pEntry->nMemberId );
|
||||
if (bDone)
|
||||
pData->PutItem( nFieldIndex, *pNewItem );
|
||||
delete pNewItem;
|
||||
}
|
||||
|
||||
if (bDone)
|
||||
|
||||
@@ -186,13 +186,12 @@ void SAL_CALL ScDocDefaultsObj::setPropertyValue(
|
||||
else
|
||||
{
|
||||
ScDocumentPool* pPool = pDocShell->GetDocument().GetPool();
|
||||
SfxPoolItem* pNewItem = pPool->GetDefaultItem(pEntry->nWID).Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pPool->GetDefaultItem(pEntry->nWID).Clone());
|
||||
|
||||
if( !pNewItem->PutValue( aValue, pEntry->nMemberId ) )
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
pPool->SetPoolDefaultItem( *pNewItem );
|
||||
delete pNewItem; // copied in SetPoolDefaultItem
|
||||
|
||||
ItemsChanged();
|
||||
}
|
||||
|
||||
@@ -356,13 +356,13 @@ void FuConstruct::SetStyleSheet( SfxItemSet& rAttr, SdrObject* pObj,
|
||||
if (pSheet)
|
||||
{
|
||||
pObj->SetStyleSheet(pSheet, false);
|
||||
SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
|
||||
SfxItemSet aAttr(mpView->GetDefaultAttr());
|
||||
aAttr.Put(pSheet->GetItemSet().Get(XATTR_FILLSTYLE));
|
||||
pObj->SetMergedItemSet(aAttr);
|
||||
}
|
||||
else
|
||||
{
|
||||
SfxItemSet aAttr(*mpView->GetDefaultAttr().Clone());
|
||||
SfxItemSet aAttr(mpView->GetDefaultAttr());
|
||||
rAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
|
||||
pObj->SetMergedItemSet(aAttr);
|
||||
}
|
||||
|
||||
@@ -942,11 +942,11 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
|
||||
pTargetFrame = &SfxViewFrame::Current()->GetFrame();
|
||||
|
||||
// check if caller has set a callback
|
||||
const SfxLinkItem* pLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK);
|
||||
std::unique_ptr<SfxLinkItem> pLinkItem;
|
||||
|
||||
// remove from Itemset, because it confuses the parameter transformation
|
||||
if ( pLinkItem )
|
||||
pLinkItem = static_cast<SfxLinkItem*>( pLinkItem->Clone() );
|
||||
if (auto pParamLinkItem = rReq.GetArg<SfxLinkItem>(SID_DONELINK))
|
||||
pLinkItem.reset( static_cast<SfxLinkItem*>( pParamLinkItem->Clone() ) );
|
||||
|
||||
rReq.RemoveItem( SID_DONELINK );
|
||||
|
||||
@@ -1111,7 +1111,6 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
|
||||
{
|
||||
pLinkItem->GetValue().Call(pRetValue);
|
||||
}
|
||||
delete pLinkItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1018,20 +1018,18 @@ void SfxBindings::Execute_Impl( SfxRequest& aReq, const SfxSlot* pSlot, SfxShell
|
||||
{
|
||||
// we can toggle Bools
|
||||
bool bOldValue = pOldBoolItem->GetValue();
|
||||
SfxBoolItem *pNewItem = static_cast<SfxBoolItem*>(pOldItem->Clone());
|
||||
std::unique_ptr<SfxBoolItem> pNewItem(static_cast<SfxBoolItem*>(pOldItem->Clone()));
|
||||
pNewItem->SetValue( !bOldValue );
|
||||
aReq.AppendItem( *pNewItem );
|
||||
delete pNewItem;
|
||||
}
|
||||
else if ( dynamic_cast< const SfxEnumItemInterface *>( pOldItem ) != nullptr &&
|
||||
static_cast<const SfxEnumItemInterface *>(pOldItem)->HasBoolValue())
|
||||
{
|
||||
// and Enums with Bool-Interface
|
||||
SfxEnumItemInterface *pNewItem =
|
||||
static_cast<SfxEnumItemInterface*>(pOldItem->Clone());
|
||||
std::unique_ptr<SfxEnumItemInterface> pNewItem(
|
||||
static_cast<SfxEnumItemInterface*>(pOldItem->Clone()));
|
||||
pNewItem->SetBoolValue(!static_cast<const SfxEnumItemInterface *>(pOldItem)->GetBoolValue());
|
||||
aReq.AppendItem( *pNewItem );
|
||||
delete pNewItem;
|
||||
}
|
||||
else {
|
||||
OSL_FAIL( "Toggle only for Enums and Bools allowed" );
|
||||
|
||||
@@ -129,9 +129,9 @@ void SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const
|
||||
|
||||
std::unique_ptr<SfxPoolItem> SfxPoolItem::CloneSetWhich( sal_uInt16 nNewWhich ) const
|
||||
{
|
||||
SfxPoolItem* pItem = Clone();
|
||||
std::unique_ptr<SfxPoolItem> pItem(Clone());
|
||||
pItem->SetWhich(nNewWhich);
|
||||
return std::unique_ptr<SfxPoolItem>(pItem);
|
||||
return pItem;
|
||||
}
|
||||
|
||||
bool SfxPoolItem::IsVoidItem() const
|
||||
|
||||
@@ -1126,7 +1126,7 @@ IMPL_LINK(SdrItemBrowser, ChangedHdl, SdrItemBrowserControl&, rBrowse, void)
|
||||
|| aNewText == "DEFAULT" );
|
||||
|
||||
if (!bDel) {
|
||||
SfxPoolItem* pNewItem=aSet.Get(pEntry->nWhichId).Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(aSet.Get(pEntry->nWhichId).Clone());
|
||||
sal_Int32 nLongVal = aNewText.toInt32();
|
||||
if (pEntry->bCanNum) {
|
||||
if (nLongVal>pEntry->nMax) nLongVal=pEntry->nMax;
|
||||
@@ -1149,20 +1149,20 @@ IMPL_LINK(SdrItemBrowser, ChangedHdl, SdrItemBrowserControl&, rBrowse, void)
|
||||
nLongY = s.toInt32();
|
||||
}
|
||||
switch (pEntry->eItemType) {
|
||||
case ItemType::BYTE : static_cast<SfxByteItem *>(pNewItem)->SetValue(static_cast<sal_uInt8>(nLongVal)); break;
|
||||
case ItemType::INT16 : static_cast<SfxInt16Item *>(pNewItem)->SetValue(static_cast<sal_Int16>(nLongVal)); break;
|
||||
case ItemType::UINT16: static_cast<SfxUInt16Item*>(pNewItem)->SetValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::BYTE : static_cast<SfxByteItem *>(pNewItem.get())->SetValue(static_cast<sal_uInt8>(nLongVal)); break;
|
||||
case ItemType::INT16 : static_cast<SfxInt16Item *>(pNewItem.get())->SetValue(static_cast<sal_Int16>(nLongVal)); break;
|
||||
case ItemType::UINT16: static_cast<SfxUInt16Item*>(pNewItem.get())->SetValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::INT32: {
|
||||
if(dynamic_cast<const SdrAngleItem *>(pNewItem) != nullptr)
|
||||
if(dynamic_cast<const SdrAngleItem *>(pNewItem.get()))
|
||||
{
|
||||
aNewText = aNewText.replace(',', '.');
|
||||
double nVal = aNewText.toFloat();
|
||||
nLongVal = static_cast<sal_Int32>(nVal * 100.0 + 0.5);
|
||||
}
|
||||
static_cast<SfxInt32Item *>(pNewItem)->SetValue(nLongVal);
|
||||
static_cast<SfxInt32Item *>(pNewItem.get())->SetValue(nLongVal);
|
||||
} break;
|
||||
case ItemType::UINT32: static_cast<SfxUInt32Item*>(pNewItem)->SetValue(aNewText.toInt32()); break;
|
||||
case ItemType::ENUM : static_cast<SfxEnumItemInterface*>(pNewItem)->SetEnumValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::UINT32: static_cast<SfxUInt32Item*>(pNewItem.get())->SetValue(aNewText.toInt32()); break;
|
||||
case ItemType::ENUM : static_cast<SfxEnumItemInterface*>(pNewItem.get())->SetEnumValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::BOOL: {
|
||||
aNewText = aNewText.toAsciiUpperCase();
|
||||
if (aNewText == "TRUE") nLongVal=1;
|
||||
@@ -1171,27 +1171,27 @@ IMPL_LINK(SdrItemBrowser, ChangedHdl, SdrItemBrowserControl&, rBrowse, void)
|
||||
if (aNewText == "EIN") nLongVal=1;
|
||||
if (aNewText == "ON") nLongVal=1;
|
||||
if (aNewText == "YES") nLongVal=1;
|
||||
static_cast<SfxBoolItem*>(pNewItem)->SetValue(nLongVal == 1);
|
||||
static_cast<SfxBoolItem*>(pNewItem.get())->SetValue(nLongVal == 1);
|
||||
} break;
|
||||
case ItemType::FLAG : static_cast<SfxFlagItem *>(pNewItem)->SetValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::STRING: static_cast<SfxStringItem*>(pNewItem)->SetValue(aNewText); break;
|
||||
case ItemType::POINT : static_cast<SfxPointItem*>(pNewItem)->SetValue(Point(nLongX,nLongY)); break;
|
||||
case ItemType::FLAG : static_cast<SfxFlagItem *>(pNewItem.get())->SetValue(static_cast<sal_uInt16>(nLongVal)); break;
|
||||
case ItemType::STRING: static_cast<SfxStringItem*>(pNewItem.get())->SetValue(aNewText); break;
|
||||
case ItemType::POINT : static_cast<SfxPointItem*>(pNewItem.get())->SetValue(Point(nLongX,nLongY)); break;
|
||||
case ItemType::RECT : break;
|
||||
case ItemType::RANGE : {
|
||||
static_cast<SfxRangeItem*>(pNewItem)->From()=static_cast<sal_uInt16>(nLongX);
|
||||
static_cast<SfxRangeItem*>(pNewItem)->From()=static_cast<sal_uInt16>(nLongY);
|
||||
static_cast<SfxRangeItem*>(pNewItem.get())->From()=static_cast<sal_uInt16>(nLongX);
|
||||
static_cast<SfxRangeItem*>(pNewItem.get())->From()=static_cast<sal_uInt16>(nLongY);
|
||||
} break;
|
||||
case ItemType::FRACTION: {
|
||||
if (!bPairX) nLongX=1;
|
||||
if (!bPairY) nLongY=1;
|
||||
static_cast<SdrFractionItem*>(pNewItem)->SetValue(Fraction(nLongX,nLongY));
|
||||
static_cast<SdrFractionItem*>(pNewItem.get())->SetValue(Fraction(nLongX,nLongY));
|
||||
} break;
|
||||
case ItemType::XCOLOR: break;
|
||||
case ItemType::COLOR: break;
|
||||
case ItemType::FONT: {
|
||||
static_cast<SvxFontItem*>(pNewItem)->SetFamily( FAMILY_DONTKNOW );
|
||||
static_cast<SvxFontItem*>(pNewItem)->SetFamilyName(aNewText);
|
||||
static_cast<SvxFontItem*>(pNewItem)->SetStyleName(OUString());
|
||||
static_cast<SvxFontItem*>(pNewItem.get())->SetFamily( FAMILY_DONTKNOW );
|
||||
static_cast<SvxFontItem*>(pNewItem.get())->SetFamilyName(aNewText);
|
||||
static_cast<SvxFontItem*>(pNewItem.get())->SetStyleName(OUString());
|
||||
} break;
|
||||
case ItemType::FONTHEIGHT: {
|
||||
sal_uInt32 nHgt=0;
|
||||
@@ -1201,20 +1201,19 @@ IMPL_LINK(SdrItemBrowser, ChangedHdl, SdrItemBrowserControl&, rBrowse, void)
|
||||
} else {
|
||||
nHgt=static_cast<sal_uInt32>(nLongVal);
|
||||
}
|
||||
static_cast<SvxFontHeightItem*>(pNewItem)->SetHeight(nHgt,nProp);
|
||||
static_cast<SvxFontHeightItem*>(pNewItem.get())->SetHeight(nHgt,nProp);
|
||||
} break;
|
||||
case ItemType::FONTWIDTH: {
|
||||
sal_uInt16 nProp=100;
|
||||
if (aNewText.indexOf('%') != -1) {
|
||||
nProp=static_cast<sal_uInt16>(nLongVal);
|
||||
}
|
||||
static_cast<SvxCharScaleWidthItem*>(pNewItem)->SetValue(nProp);
|
||||
static_cast<SvxCharScaleWidthItem*>(pNewItem.get())->SetValue(nProp);
|
||||
} break;
|
||||
case ItemType::FIELD: break;
|
||||
default: break;
|
||||
} // switch
|
||||
aNewSet.Put(*pNewItem);
|
||||
delete pNewItem;
|
||||
}
|
||||
pView->SetAttributes(aNewSet,bDel);
|
||||
}
|
||||
|
||||
@@ -601,10 +601,9 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
|
||||
0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
|
||||
nSlotId != nEdtWhich )
|
||||
{
|
||||
SfxPoolItem* pCpy = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
|
||||
pCpy->SetWhich( nEdtWhich );
|
||||
pSdrPool->SetPoolDefaultItem( *pCpy );
|
||||
delete pCpy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1180,7 +1180,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
|
||||
// we just need to set the new page description and reset numbering
|
||||
// this keeps all other settings as in the pasted document
|
||||
if ( nStartPageNumber || pTargetPageDesc ) {
|
||||
SfxPoolItem *pNewItem;
|
||||
std::unique_ptr<SfxPoolItem> pNewItem;
|
||||
SwTextNode *aTextNd = nullptr;
|
||||
SwFormat *pFormat = nullptr;
|
||||
|
||||
@@ -1192,12 +1192,12 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
|
||||
if ( node.IsTextNode() ) {
|
||||
// every document contains at least one text node!
|
||||
aTextNd = node.GetTextNode();
|
||||
pNewItem = aTextNd->GetAttr( RES_PAGEDESC ).Clone();
|
||||
pNewItem.reset(aTextNd->GetAttr( RES_PAGEDESC ).Clone());
|
||||
break;
|
||||
}
|
||||
else if ( node.IsTableNode() ) {
|
||||
pFormat = node.GetTableNode()->GetTable().GetFrameFormat();
|
||||
pNewItem = pFormat->GetFormatAttr( RES_PAGEDESC ).Clone();
|
||||
pNewItem.reset(pFormat->GetFormatAttr( RES_PAGEDESC ).Clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1207,7 +1207,7 @@ SwNodeIndex SwDoc::AppendDoc(const SwDoc& rSource, sal_uInt16 const nStartPageNu
|
||||
SAL_INFO( "sw.docappend", "Idx Fix " << CNTNT_IDX( aFixupIdx ) );
|
||||
#endif
|
||||
// just update the original instead of overwriting
|
||||
SwFormatPageDesc *aDesc = static_cast< SwFormatPageDesc* >( pNewItem );
|
||||
SwFormatPageDesc *aDesc = static_cast< SwFormatPageDesc* >( pNewItem.get() );
|
||||
#ifdef DBG_UTIL
|
||||
if ( aDesc->GetPageDesc() )
|
||||
SAL_INFO( "sw.docappend", "PD Update " << aDesc->GetPageDesc()->GetName() );
|
||||
@@ -1222,7 +1222,6 @@ else
|
||||
aTextNd->SetAttr( *aDesc );
|
||||
else
|
||||
pFormat->SetFormatAttr( *aDesc );
|
||||
delete pNewItem;
|
||||
|
||||
#ifdef DBG_UTIL
|
||||
SAL_INFO( "sw.docappend", "Idx " << CNTNT_IDX( aDelIdx ) );
|
||||
|
||||
@@ -4215,11 +4215,10 @@ void SwDoc::ClearLineNumAttrs( SwPosition const & rPos )
|
||||
aRegH.RegisterInModify( pTextNode , *pTextNode );
|
||||
if ( pUndo )
|
||||
pUndo->AddNode( *pTextNode );
|
||||
SfxStringItem * pNewItem = static_cast<SfxStringItem*>(pFormatItem->Clone());
|
||||
std::unique_ptr<SfxStringItem> pNewItem(static_cast<SfxStringItem*>(pFormatItem->Clone()));
|
||||
pNewItem->SetValue(OUString());
|
||||
rSet.Put( *pNewItem );
|
||||
pTextNode->SetAttr( rSet );
|
||||
delete pNewItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,10 +77,9 @@ SwDrawModel::SwDrawModel(SwDoc *const pDoc)
|
||||
0 != (nEdtWhich = pSdrPool->GetWhich( nSlotId )) &&
|
||||
nSlotId != nEdtWhich )
|
||||
{
|
||||
SfxPoolItem* pCpy = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCpy(pItem->Clone());
|
||||
pCpy->SetWhich( nEdtWhich );
|
||||
pSdrPool->SetPoolDefaultItem( *pCpy );
|
||||
delete pCpy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -283,7 +283,7 @@ ToxTextGenerator::CollectAttributesForTox(const SwTextAttr& hint, SwAttrPool& po
|
||||
pItem->Which() == RES_CHRATR_POSTURE ||
|
||||
pItem->Which() == RES_CHRATR_CJK_POSTURE ||
|
||||
pItem->Which() == RES_CHRATR_CTL_POSTURE) {
|
||||
SfxPoolItem* clonedItem = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> clonedItem(pItem->Clone());
|
||||
retval->Put(*clonedItem);
|
||||
}
|
||||
if (aIter.IsAtEnd()) {
|
||||
|
||||
@@ -135,48 +135,42 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes
|
||||
// from now on this descriptor is responsible for the content nodes!
|
||||
const SfxPoolItem* pItem;
|
||||
rDest.GetMaster().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
SfxPoolItem *pNewItem = pItem->Clone();
|
||||
SwFrameFormat* pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
|
||||
SwFrameFormat* pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceHead.GetHeaderFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
|
||||
// Let the source page description point to zero node position,
|
||||
// it loses the responsible and can be destroyed without removing the content nodes.
|
||||
rSource.GetMaster().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
|
||||
if( !rDest.IsHeaderShared() )
|
||||
{
|
||||
// Same procedure for unshared header..
|
||||
const SwFormatHeader& rSourceLeftHead = rSource.GetLeft().GetHeader();
|
||||
rDest.GetLeft().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceLeftHead.GetHeaderFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
rSource.GetLeft().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
}
|
||||
if (!rDest.IsFirstShared())
|
||||
{
|
||||
// Same procedure for unshared header..
|
||||
const SwFormatHeader& rSourceFirstMasterHead = rSource.GetFirstMaster().GetHeader();
|
||||
rDest.GetFirstMaster().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceFirstMasterHead.GetHeaderFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
rSource.GetFirstMaster().GetAttrSet().GetItemState( RES_HEADER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem)->GetHeaderFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatHeader*>(pNewItem.get())->GetHeaderFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
}
|
||||
}
|
||||
// Same procedure for footers...
|
||||
@@ -187,47 +181,39 @@ void SwUndoPageDesc::ExchangeContentNodes( SwPageDesc& rSource, SwPageDesc &rDes
|
||||
|
||||
const SfxPoolItem* pItem;
|
||||
rDest.GetMaster().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
SfxPoolItem *pNewItem = pItem->Clone();
|
||||
SwFrameFormat *pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
|
||||
SwFrameFormat *pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceFoot.GetFooterFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
|
||||
rSource.GetMaster().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
|
||||
if( !rDest.IsFooterShared() )
|
||||
{
|
||||
const SwFormatFooter& rSourceLeftFoot = rSource.GetLeft().GetFooter();
|
||||
rDest.GetLeft().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceLeftFoot.GetFooterFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
rSource.GetLeft().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
}
|
||||
if (rDest.IsFirstShared())
|
||||
return;
|
||||
|
||||
const SwFormatFooter& rSourceFirstMasterFoot = rSource.GetFirstMaster().GetFooter();
|
||||
rDest.GetFirstMaster().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( rSourceFirstMasterFoot.GetFooterFormat()->GetContent() );
|
||||
delete pNewItem;
|
||||
rSource.GetFirstMaster().GetAttrSet().GetItemState( RES_FOOTER, false, &pItem );
|
||||
pNewItem = pItem->Clone();
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem)->GetFooterFormat();
|
||||
pNewItem.reset(pItem->Clone());
|
||||
pNewFormat = static_cast<SwFormatFooter*>(pNewItem.get())->GetFooterFormat();
|
||||
pNewFormat->SetFormatAttr( SwFormatContent() );
|
||||
delete pNewItem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SwUndoPageDesc::UndoImpl(::sw::UndoRedoContext &)
|
||||
|
||||
@@ -865,10 +865,10 @@ void SwUndoDefaultAttr::UndoImpl(::sw::UndoRedoContext & rContext)
|
||||
}
|
||||
if (m_pTabStop)
|
||||
{
|
||||
SvxTabStopItem* pOld = static_cast<SvxTabStopItem*>(
|
||||
rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() );
|
||||
std::unique_ptr<SvxTabStopItem> pOld(static_cast<SvxTabStopItem*>(
|
||||
rDoc.GetDefault( RES_PARATR_TABSTOP ).Clone() ));
|
||||
rDoc.SetDefault( *m_pTabStop );
|
||||
m_pTabStop.reset( pOld );
|
||||
m_pTabStop = std::move( pOld );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -88,8 +88,8 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName,
|
||||
SwStyleNameMapper::FillUIName(uStyle, sStyle, SwGetPoolIdFromName::ChrFmt );
|
||||
SwDocStyleSheet* pStyle =
|
||||
static_cast<SwDocStyleSheet*>(m_pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, SfxStyleFamily::Char));
|
||||
SwFormatDrop* pDrop = nullptr;
|
||||
SwFormatCharFormat *pCharFormat = nullptr;
|
||||
std::unique_ptr<SwFormatDrop> pDrop;
|
||||
std::unique_ptr<SwFormatCharFormat> pCharFormat;
|
||||
if(!pStyle)
|
||||
throw lang::IllegalArgumentException();
|
||||
|
||||
@@ -99,26 +99,22 @@ void SAL_CALL SwXTextDefaults::setPropertyValue( const OUString& rPropertyName,
|
||||
|
||||
if (RES_PARATR_DROP == pMap->nWID)
|
||||
{
|
||||
pDrop = static_cast<SwFormatDrop*>(rItem.Clone()); // because rItem is const...
|
||||
pDrop.reset(static_cast<SwFormatDrop*>(rItem.Clone())); // because rItem is const...
|
||||
pDrop->SetCharFormat(xStyle->GetCharFormat());
|
||||
m_pDoc->SetDefault(*pDrop);
|
||||
}
|
||||
else // RES_TXTATR_CHARFMT == pMap->nWID
|
||||
{
|
||||
pCharFormat = static_cast<SwFormatCharFormat*>(rItem.Clone()); // because rItem is const...
|
||||
pCharFormat.reset(static_cast<SwFormatCharFormat*>(rItem.Clone())); // because rItem is const...
|
||||
pCharFormat->SetCharFormat(xStyle->GetCharFormat());
|
||||
m_pDoc->SetDefault(*pCharFormat);
|
||||
}
|
||||
|
||||
delete pDrop;
|
||||
delete pCharFormat;
|
||||
}
|
||||
else
|
||||
{
|
||||
SfxPoolItem * pNewItem = rItem.Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(rItem.Clone());
|
||||
pNewItem->PutValue( aValue, pMap->nMemberId);
|
||||
m_pDoc->SetDefault(*pNewItem);
|
||||
delete pNewItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1104,10 +1104,9 @@ bool SwGraphicProperties_Impl::AnyToItemSet(
|
||||
sal_uInt8 nMId = RES_GRFATR_CROPGRF == nIDs[nIndex] ? CONVERT_TWIPS : 0;
|
||||
if(GetProperty(nIDs[nIndex], nMId, pAny ))
|
||||
{
|
||||
SfxPoolItem* pItem = ::GetDfltAttr( nIDs[nIndex] )->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pItem(::GetDfltAttr( nIDs[nIndex] )->Clone());
|
||||
bRet &= pItem->PutValue(*pAny, nMId );
|
||||
rGrSet.Put(*pItem);
|
||||
delete pItem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2705,12 +2704,12 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
|
||||
UnoActionContext aCont(pDoc);
|
||||
if(m_pCopySource)
|
||||
{
|
||||
SwFormatAnchor* pAnchorItem = nullptr;
|
||||
std::unique_ptr<SwFormatAnchor> pAnchorItem;
|
||||
// the frame is inserted bound to page
|
||||
// to prevent conflicts if the to-be-anchored position is part of the to-be-copied text
|
||||
if (eAnchorId != RndStdIds::FLY_AT_PAGE)
|
||||
{
|
||||
pAnchorItem = static_cast<SwFormatAnchor*>(aFrameSet.Get(RES_ANCHOR).Clone());
|
||||
pAnchorItem.reset(static_cast<SwFormatAnchor*>(aFrameSet.Get(RES_ANCHOR).Clone()));
|
||||
aFrameSet.Put( SwFormatAnchor( RndStdIds::FLY_AT_PAGE, 1 ));
|
||||
}
|
||||
|
||||
@@ -2726,7 +2725,6 @@ void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRan
|
||||
SfxItemSet aAnchorSet( pDoc->GetAttrPool(), svl::Items<RES_ANCHOR, RES_ANCHOR>{} );
|
||||
aAnchorSet.Put( *pAnchorItem );
|
||||
pDoc->SetFlyFrameAttr( *pFormat, aAnchorSet );
|
||||
delete pAnchorItem;
|
||||
}
|
||||
m_pCopySource.reset();
|
||||
}
|
||||
|
||||
@@ -1613,7 +1613,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
|
||||
{
|
||||
SvxBrushItem* pSetBrush = nullptr;
|
||||
Size* pSetSize = nullptr;
|
||||
SwFormatVertOrient* pSetVOrient = nullptr;
|
||||
std::unique_ptr<SwFormatVertOrient> pSetVOrient;
|
||||
bool bCharStyleNameSet = false;
|
||||
|
||||
for(size_t i = 0; i < SAL_N_ELEMENTS( aNumPropertyNames ) && !bExcept && !bWrongArg; ++i)
|
||||
@@ -1983,9 +1983,9 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
|
||||
if(!pSetVOrient)
|
||||
{
|
||||
if(aFormat.GetGraphicOrientation())
|
||||
pSetVOrient = static_cast<SwFormatVertOrient*>(aFormat.GetGraphicOrientation()->Clone());
|
||||
pSetVOrient.reset( static_cast<SwFormatVertOrient*>(aFormat.GetGraphicOrientation()->Clone()) );
|
||||
else
|
||||
pSetVOrient = new SwFormatVertOrient;
|
||||
pSetVOrient.reset(new SwFormatVertOrient);
|
||||
}
|
||||
pSetVOrient->PutValue(pProp->Value, MID_VERTORIENT_ORIENT);
|
||||
}
|
||||
@@ -2041,7 +2041,7 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
|
||||
if(pSetBrush)
|
||||
{
|
||||
if(!pSetVOrient && aFormat.GetGraphicOrientation())
|
||||
pSetVOrient = new SwFormatVertOrient(*aFormat.GetGraphicOrientation());
|
||||
pSetVOrient.reset( new SwFormatVertOrient(*aFormat.GetGraphicOrientation()) );
|
||||
|
||||
if(!pSetSize)
|
||||
{
|
||||
@@ -2069,7 +2069,6 @@ void SwXNumberingRules::SetPropertiesToNumFormat(
|
||||
}
|
||||
delete pSetBrush;
|
||||
delete pSetSize;
|
||||
delete pSetVOrient;
|
||||
}
|
||||
|
||||
if(bWrongArg)
|
||||
|
||||
@@ -239,10 +239,9 @@ static void PutEEPoolItem( SfxItemSet &rEEItemSet,
|
||||
|
||||
if( nEEWhich )
|
||||
{
|
||||
SfxPoolItem *pEEItem = rSwItem.Clone();
|
||||
std::unique_ptr<SfxPoolItem> pEEItem(rSwItem.Clone());
|
||||
pEEItem->SetWhich( nEEWhich );
|
||||
rEEItemSet.Put( *pEEItem );
|
||||
delete pEEItem;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,10 +114,9 @@ void SwHTMLWriter::GetEEAttrsFromDrwObj( SfxItemSet& rItemSet,
|
||||
pEEItem = &rObjItemSet.GetPool()->GetDefaultItem(nEEWhich);
|
||||
|
||||
// now we clone the item with the which id of the writer
|
||||
SfxPoolItem *pSwItem = pEEItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pSwItem(pEEItem->Clone());
|
||||
pSwItem->SetWhich( nSwWhich );
|
||||
rItemSet.Put( *pSwItem );
|
||||
delete pSwItem;
|
||||
}
|
||||
|
||||
nEEWhich = aIter.NextWhich();
|
||||
|
||||
@@ -1155,7 +1155,7 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
|
||||
m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
|
||||
{
|
||||
// use always the SW-Which Id !
|
||||
SfxPoolItem* pI = i->pAttr->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pI(i->pAttr->Clone());
|
||||
pI->SetWhich( nWhich );
|
||||
// Will this item produce a <w:sz> element?
|
||||
bool bFontSizeItem = nWhich == RES_CHRATR_FONTSIZE || nWhich == RES_CHRATR_CJK_FONTSIZE;
|
||||
@@ -1163,7 +1163,6 @@ void MSWord_SdrAttrIter::OutAttr( sal_Int32 nSwPos )
|
||||
m_rExport.AttrOutput().OutputItem( *pI );
|
||||
if (bFontSizeItem)
|
||||
m_rExport.m_bFontSizeWritten = true;
|
||||
delete pI;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1290,11 +1289,10 @@ void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>*
|
||||
: ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END ) ) )
|
||||
{
|
||||
// use always the SW-Which Id !
|
||||
SfxPoolItem* pI = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pI(pItem->Clone());
|
||||
pI->SetWhich( nWhich );
|
||||
if (m_rExport.CollapseScriptsforWordOk(nScript,nWhich))
|
||||
m_rExport.AttrOutput().OutputItem(*pI);
|
||||
delete pI;
|
||||
}
|
||||
} while( !aIter.IsAtEnd() && nullptr != ( pItem = aIter.NextItem() ) );
|
||||
m_rExport.SetCurItemSet( pOldSet );
|
||||
|
||||
@@ -512,10 +512,9 @@ void SwWW8ImplReader::InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl )
|
||||
( SfxItemState::SET != rS.GetItemState(nWhich, false) )
|
||||
)
|
||||
{
|
||||
SfxPoolItem* pCopy = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCopy(pItem->Clone());
|
||||
pCopy->SetWhich( nWhich );
|
||||
rS.Put( *pCopy );
|
||||
delete pCopy;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -728,10 +727,9 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp,
|
||||
nWhich != nSlotId
|
||||
)
|
||||
{
|
||||
SfxPoolItem* pCopy = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pCopy(pItem->Clone());
|
||||
pCopy->SetWhich( nWhich );
|
||||
pS->Put( *pCopy );
|
||||
delete pCopy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3540,14 +3540,13 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, sh
|
||||
{
|
||||
if( SfxItemState::SET == m_pCurrentColl->GetItemState( RES_CHRATR_UNDERLINE, false ) )
|
||||
{
|
||||
const SwAttrSet& aSet = m_pCurrentColl->GetAttrSet();
|
||||
SvxUnderlineItem *pUnderline
|
||||
= static_cast<SvxUnderlineItem *>(aSet.Get( RES_CHRATR_UNDERLINE, false ).Clone());
|
||||
if (pUnderline && nLen >= 4)
|
||||
if (nLen >= 4)
|
||||
{
|
||||
const SwAttrSet& aSet = m_pCurrentColl->GetAttrSet();
|
||||
std::unique_ptr<SvxUnderlineItem> pUnderline(
|
||||
static_cast<SvxUnderlineItem *>(aSet.Get( RES_CHRATR_UNDERLINE, false ).Clone()));
|
||||
pUnderline->SetColor( msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) );
|
||||
m_pCurrentColl->SetFormatAttr( *pUnderline );
|
||||
delete pUnderline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3555,13 +3554,11 @@ void SwWW8ImplReader::Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, sh
|
||||
{
|
||||
if ( SfxItemState::SET == m_xCurrentItemSet->GetItemState( RES_CHRATR_UNDERLINE, false ) )
|
||||
{
|
||||
SvxUnderlineItem *pUnderline
|
||||
= static_cast<SvxUnderlineItem*>(m_xCurrentItemSet->Get(RES_CHRATR_UNDERLINE, false).Clone());
|
||||
if (pUnderline && nLen >= 4)
|
||||
if (nLen >= 4)
|
||||
{
|
||||
std::unique_ptr<SvxUnderlineItem> pUnderline(static_cast<SvxUnderlineItem*>(m_xCurrentItemSet->Get(RES_CHRATR_UNDERLINE, false).Clone()));
|
||||
pUnderline->SetColor( msfilter::util::BGRToRGB(SVBT32ToUInt32(pData)) );
|
||||
m_xCurrentItemSet->Put( *pUnderline );
|
||||
delete pUnderline;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4541,10 +4538,9 @@ void SwWW8ImplReader::Read_BoolItem( sal_uInt16 nId, const sal_uInt8* pData, sho
|
||||
m_xCtrlStck->SetAttr( *m_pPaM->GetPoint(), nId );
|
||||
else
|
||||
{
|
||||
SfxBoolItem* pI = static_cast<SfxBoolItem*>(GetDfltAttr( nId )->Clone());
|
||||
std::unique_ptr<SfxBoolItem> pI(static_cast<SfxBoolItem*>(GetDfltAttr( nId )->Clone()));
|
||||
pI->SetValue( 0 != *pData );
|
||||
NewAttr( *pI );
|
||||
delete pI;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
|
||||
{
|
||||
sal_Int16 nAttr = xAttrList->getLength();
|
||||
|
||||
SvXMLAttrContainerItem *pUnknownItem = nullptr;
|
||||
std::unique_ptr<SvXMLAttrContainerItem> pUnknownItem;
|
||||
for( sal_Int16 i=0; i < nAttr; i++ )
|
||||
{
|
||||
const OUString& rAttrName = xAttrList->getNameByIndex( i );
|
||||
@@ -117,7 +117,7 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
|
||||
// do we have an item?
|
||||
if(eState >= SfxItemState::DEFAULT && pItem)
|
||||
{
|
||||
SfxPoolItem *pNewItem = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
|
||||
bool bPut = false;
|
||||
|
||||
if( 0 == (pEntry->nMemberId&MID_SW_FLAG_SPECIAL_ITEM_IMPORT) )
|
||||
@@ -136,8 +136,6 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
|
||||
|
||||
if( bPut )
|
||||
rSet.Put( *pNewItem );
|
||||
|
||||
delete pNewItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -158,16 +156,11 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
|
||||
if( SfxItemState::SET == rSet.GetItemState( nUnknownWhich, true,
|
||||
&pItem ) )
|
||||
{
|
||||
SfxPoolItem *pNew = pItem->Clone();
|
||||
pUnknownItem = dynamic_cast<SvXMLAttrContainerItem*>( pNew );
|
||||
OSL_ENSURE( pUnknownItem,
|
||||
"SvXMLAttrContainerItem expected" );
|
||||
if( !pUnknownItem )
|
||||
delete pNew;
|
||||
pUnknownItem.reset( static_cast<SvXMLAttrContainerItem*>( pItem->Clone() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
pUnknownItem = new SvXMLAttrContainerItem( nUnknownWhich );
|
||||
pUnknownItem.reset( new SvXMLAttrContainerItem( nUnknownWhich ) );
|
||||
}
|
||||
}
|
||||
if( pUnknownItem )
|
||||
@@ -184,7 +177,6 @@ void SvXMLImportItemMapper::importXML( SfxItemSet& rSet,
|
||||
if( pUnknownItem )
|
||||
{
|
||||
rSet.Put( *pUnknownItem );
|
||||
delete pUnknownItem;
|
||||
}
|
||||
|
||||
finished(rSet, rUnitConverter);
|
||||
|
||||
@@ -214,7 +214,7 @@ void SwXMLImportTableItemMapper_Impl::finished(
|
||||
// do we have an item?
|
||||
if (eState >= SfxItemState::DEFAULT && pItem)
|
||||
{
|
||||
SfxPoolItem *const pNewItem = pItem->Clone();
|
||||
std::unique_ptr<SfxPoolItem> pNewItem(pItem->Clone());
|
||||
bool const bPut = PutXMLValue(
|
||||
*pNewItem, m_FoMarginValue, Ids[i][1], rUnitConverter);
|
||||
if (bPut)
|
||||
|
||||
@@ -111,10 +111,9 @@ bool SwParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
|
||||
const SfxUInt16Item* pOldOutlineLv = static_cast<const SfxUInt16Item*>(GetOldItem( *rSet, SID_ATTR_PARA_OUTLINE_LEVEL));
|
||||
if (pOldOutlineLv)
|
||||
{
|
||||
SfxUInt16Item* pOutlineLv = static_cast<SfxUInt16Item*>(pOldOutlineLv->Clone());
|
||||
std::unique_ptr<SfxUInt16Item> pOutlineLv(static_cast<SfxUInt16Item*>(pOldOutlineLv->Clone()));
|
||||
pOutlineLv->SetValue( aOutlineLv );
|
||||
rSet->Put(*pOutlineLv);
|
||||
delete pOutlineLv;
|
||||
bModified = true;
|
||||
}
|
||||
}
|
||||
@@ -125,12 +124,11 @@ bool SwParagraphNumTabPage::FillItemSet( SfxItemSet* rSet )
|
||||
if (m_xNumberStyleLB->get_active())
|
||||
aStyle = m_xNumberStyleLB->get_active_text();
|
||||
const SfxStringItem* pOldRule = static_cast<const SfxStringItem*>(GetOldItem( *rSet, SID_ATTR_PARA_NUMRULE));
|
||||
SfxStringItem* pRule = pOldRule ? static_cast<SfxStringItem*>(pOldRule->Clone()) : nullptr;
|
||||
if (pRule)
|
||||
if (pOldRule)
|
||||
{
|
||||
std::unique_ptr<SfxStringItem> pRule(static_cast<SfxStringItem*>(pOldRule->Clone()));
|
||||
pRule->SetValue(aStyle);
|
||||
rSet->Put(*pRule);
|
||||
delete pRule;
|
||||
bModified = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,19 +111,13 @@ void PageOrientationControl::ExecuteOrientationChange( const bool bLandscape )
|
||||
|
||||
const SfxPoolItem* pItem;
|
||||
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_SIZE, pItem);
|
||||
SvxSizeItem* pSizeItem = static_cast<SvxSizeItem*>(pItem->Clone());
|
||||
if ( pSizeItem )
|
||||
mpPageSizeItem.reset( pSizeItem );
|
||||
mpPageSizeItem.reset( static_cast<SvxSizeItem*>(pItem->Clone()) );
|
||||
|
||||
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_LRSPACE, pItem);
|
||||
SvxLongLRSpaceItem* pLRItem = static_cast<SvxLongLRSpaceItem*>(pItem->Clone());
|
||||
if ( pLRItem )
|
||||
mpPageLRMarginItem.reset( pLRItem );
|
||||
mpPageLRMarginItem.reset( static_cast<SvxLongLRSpaceItem*>(pItem->Clone()) );
|
||||
|
||||
SfxViewFrame::Current()->GetBindings().GetDispatcher()->QueryState(SID_ATTR_PAGE_ULSPACE, pItem);
|
||||
SvxLongULSpaceItem* pULItem = static_cast<SvxLongULSpaceItem*>(pItem->Clone());
|
||||
if ( pULItem )
|
||||
mpPageULMarginItem.reset( pULItem );
|
||||
mpPageULMarginItem.reset( static_cast<SvxLongULSpaceItem*>(pItem->Clone()) );
|
||||
|
||||
{
|
||||
// set new page orientation
|
||||
|
||||
Reference in New Issue
Block a user