[Libreoffice-commits] core.git: 2 commits - sc/source starmath/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Fri Jan 18 06:49:55 UTC 2019
sc/source/core/data/patattr.cxx | 7 +++----
sc/source/core/data/table4.cxx | 7 ++-----
sc/source/core/data/validat.cxx | 9 ++++-----
sc/source/core/tool/editutil.cxx | 6 +++---
sc/source/ui/app/inputhdl.cxx | 7 +++----
sc/source/ui/docshell/docsh5.cxx | 8 ++++----
starmath/source/accessibility.cxx | 12 ++++++------
starmath/source/cursor.cxx | 6 +++---
starmath/source/mathmlexport.cxx | 10 ++++------
9 files changed, 32 insertions(+), 40 deletions(-)
New commits:
commit a7fea048dddab17989eaf1097d400aa5bfadf78f
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 17 16:47:29 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 18 07:49:38 2019 +0100
use unique_ptr in starmath
Change-Id: Ib9c555507d5271343424686f2321ae13efcbf41a
Reviewed-on: https://gerrit.libreoffice.org/66550
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 85daa5092843..5c3a1a15314e 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -486,12 +486,12 @@ awt::Rectangle SAL_CALL SmGraphicAccessible::getCharacterBounds( sal_Int32 nInde
Point aTLPos (pWin->GetFormulaDrawPos() + aOffset);
Size aSize (pNode->GetSize());
- long* pXAry = new long[ aNodeText.getLength() ];
+ std::unique_ptr<long[]> pXAry(new long[ aNodeText.getLength() ]);
pWin->SetFont( pNode->GetFont() );
- pWin->GetTextArray( aNodeText, pXAry, 0, aNodeText.getLength() );
+ pWin->GetTextArray( aNodeText, pXAry.get(), 0, aNodeText.getLength() );
aTLPos.AdjustX(nNodeIndex > 0 ? pXAry[nNodeIndex - 1] : 0 );
aSize.setWidth( nNodeIndex > 0 ? pXAry[nNodeIndex] - pXAry[nNodeIndex - 1] : pXAry[nNodeIndex] );
- delete[] pXAry;
+ pXAry.reset();
aTLPos = pWin->LogicToPixel( aTLPos );
aSize = pWin->LogicToPixel( aSize );
@@ -556,15 +556,15 @@ sal_Int32 SAL_CALL SmGraphicAccessible::getIndexAtPoint( const awt::Point& aPoin
long nNodeX = pNode->GetLeft();
- long* pXAry = new long[ aTxt.getLength() ];
+ std::unique_ptr<long[]> pXAry(new long[ aTxt.getLength() ]);
pWin->SetFont( pNode->GetFont() );
- pWin->GetTextArray( aTxt, pXAry, 0, aTxt.getLength() );
+ pWin->GetTextArray( aTxt, pXAry.get(), 0, aTxt.getLength() );
for (sal_Int32 i = 0; i < aTxt.getLength() && nRes == -1; ++i)
{
if (pXAry[i] + nNodeX > aPos.X())
nRes = i;
}
- delete[] pXAry;
+ pXAry.reset();
OSL_ENSURE( nRes >= 0 && nRes < aTxt.getLength(), "index out of range" );
OSL_ENSURE( pNode->GetAccessibleIndex() >= 0,
"invalid accessible index" );
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 6b27956cb83f..3b6a61fe6326 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -740,7 +740,7 @@ bool SmCursor::InsertRow() {
//If we're in the context of a table
if(pTable) {
- SmNodeList *pNewLineList = new SmNodeList;
+ std::unique_ptr<SmNodeList> pNewLineList(new SmNodeList);
//Move elements from pLineList to pNewLineList
pNewLineList->splice(pNewLineList->begin(), *pLineList, it, pLineList->end());
//Make sure it is valid again
@@ -750,8 +750,8 @@ bool SmCursor::InsertRow() {
if(pNewLineList->empty())
pNewLineList->push_front(new SmPlaceNode());
//Parse new line
- std::unique_ptr<SmNode> pNewLine(SmNodeListParser().Parse(pNewLineList));
- delete pNewLineList;
+ std::unique_ptr<SmNode> pNewLine(SmNodeListParser().Parse(pNewLineList.get()));
+ pNewLineList.reset();
//Wrap pNewLine in SmLineNode if needed
if(pLineParent->GetType() == SmNodeType::Line) {
std::unique_ptr<SmLineNode> pNewLineNode(new SmLineNode(SmToken(TNEWLINE, '\0', "newline")));
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 084efcf8ef77..da372cf76a26 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -721,11 +721,11 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
{
if (const SmNode *pTemp = pNode->GetSubNode(i))
{
- SvXMLElementExport *pRow=nullptr;
- SvXMLElementExport *pCell=nullptr;
+ std::unique_ptr<SvXMLElementExport> pRow;
+ std::unique_ptr<SvXMLElementExport> pCell;
if (pTable)
{
- pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, true, true);
+ pRow.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTR, true, true));
SmTokenType eAlign = TALIGNC;
if (pTemp->GetType() == SmNodeType::Align)
{
@@ -752,11 +752,9 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
AddAttribute(XML_NAMESPACE_MATH, XML_COLUMNALIGN,
eAlign == TALIGNL ? XML_LEFT : XML_RIGHT);
}
- pCell = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, true, true);
+ pCell.reset(new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTD, true, true));
}
ExportNodes(pTemp, nLevel+1);
- delete pCell;
- delete pRow;
}
}
}
commit a7ea04397bf8c6749c84fe8f0d9afc80e4cf6bb2
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Thu Jan 17 16:47:17 2019 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jan 18 07:49:24 2019 +0100
use unique_ptr in sc
Change-Id: I14ccb215e895b607c7244b420ee2cbaea8112b15
Reviewed-on: https://gerrit.libreoffice.org/66549
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx
index 1508663e0feb..d9850d7b9ed9 100644
--- a/sc/source/core/data/patattr.cxx
+++ b/sc/source/core/data/patattr.cxx
@@ -1021,7 +1021,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD
SfxItemState eItemState = pSrcSet->GetItemState( nAttrId, false, &pSrcItem );
if (eItemState==SfxItemState::SET)
{
- SfxPoolItem* pNewItem = nullptr;
+ std::unique_ptr<SfxPoolItem> pNewItem;
if ( nAttrId == ATTR_VALIDDATA )
{
@@ -1036,7 +1036,7 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD
if ( pOldData )
nNewIndex = pDestDoc->AddValidationEntry( *pOldData );
}
- pNewItem = new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex );
+ pNewItem.reset(new SfxUInt32Item( ATTR_VALIDDATA, nNewIndex ));
}
else if ( nAttrId == ATTR_VALUE_FORMAT && pDestDoc->GetFormatExchangeList() )
{
@@ -1047,14 +1047,13 @@ ScPatternAttr* ScPatternAttr::PutInPool( ScDocument* pDestDoc, ScDocument* pSrcD
if (it != pDestDoc->GetFormatExchangeList()->end())
{
sal_uInt32 nNewFormat = it->second;
- pNewItem = new SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat );
+ pNewItem.reset(new SfxUInt32Item( ATTR_VALUE_FORMAT, nNewFormat ));
}
}
if ( pNewItem )
{
pDestSet->Put(*pNewItem);
- delete pNewItem;
}
else
pDestSet->Put(*pSrcItem);
diff --git a/sc/source/core/data/table4.cxx b/sc/source/core/data/table4.cxx
index 12a23a452553..b01df1402c74 100644
--- a/sc/source/core/data/table4.cxx
+++ b/sc/source/core/data/table4.cxx
@@ -1954,10 +1954,10 @@ void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW
ScAutoFormatData* pData = rFormat.findByIndex(nFormatNo);
if (pData)
{
- ScPatternAttr* pPatternAttrs[16];
+ std::unique_ptr<ScPatternAttr> pPatternAttrs[16];
for (sal_uInt8 i = 0; i < 16; ++i)
{
- pPatternAttrs[i] = new ScPatternAttr(pDocument->GetPool());
+ pPatternAttrs[i].reset(new ScPatternAttr(pDocument->GetPool()));
pData->FillToItemSet(i, pPatternAttrs[i]->GetItemSet(), *pDocument);
}
@@ -2077,9 +2077,6 @@ void ScTable::AutoFormat( SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW
} // for nCol
} // if not equal Column
} // if not all equal
-
- for (ScPatternAttr* pPatternAttr : pPatternAttrs)
- delete pPatternAttr;
} // if AutoFormatData != NULL
} // if ValidColRow
}
diff --git a/sc/source/core/data/validat.cxx b/sc/source/core/data/validat.cxx
index c194da86e3e2..dc262625b794 100644
--- a/sc/source/core/data/validat.cxx
+++ b/sc/source/core/data/validat.cxx
@@ -774,7 +774,7 @@ bool ScValidationData::GetSelectionFromFormula(
for( nCol = 0; nCol < nCols ; nCol++ )
{
ScTokenArray aCondTokArr;
- ScTypedStrData* pEntry = nullptr;
+ std::unique_ptr<ScTypedStrData> pEntry;
OUString aValStr;
ScMatrixValue nMatVal = pValues->Get( nCol, nRow);
@@ -794,7 +794,7 @@ bool ScValidationData::GetSelectionFromFormula(
}
if( nullptr != pStrings )
- pEntry = new ScTypedStrData( aValStr, 0.0, ScTypedStrData::Standard);
+ pEntry.reset(new ScTypedStrData( aValStr, 0.0, ScTypedStrData::Standard));
if (!rCell.isEmpty() && rMatch < 0)
aCondTokArr.AddString(rSPool.intern(aValStr));
@@ -831,7 +831,7 @@ bool ScValidationData::GetSelectionFromFormula(
aCondTokArr.AddDouble( nMatVal.fVal );
}
if( nullptr != pStrings )
- pEntry = new ScTypedStrData( aValStr, nMatVal.fVal, ScTypedStrData::Value);
+ pEntry.reset(new ScTypedStrData( aValStr, nMatVal.fVal, ScTypedStrData::Value));
}
if (rMatch < 0 && !rCell.isEmpty() && IsEqualToTokenArray(rCell, rPos, aCondTokArr))
@@ -842,10 +842,9 @@ bool ScValidationData::GetSelectionFromFormula(
return true;
}
- if( nullptr != pEntry )
+ if( pEntry )
{
pStrings->push_back(*pEntry);
- delete pEntry;
n++;
}
}
diff --git a/sc/source/core/tool/editutil.cxx b/sc/source/core/tool/editutil.cxx
index 16df499e903f..5f3af3d55702 100644
--- a/sc/source/core/tool/editutil.cxx
+++ b/sc/source/core/tool/editutil.cxx
@@ -623,7 +623,7 @@ void ScEditEngineDefaulter::RepeatDefaults()
void ScEditEngineDefaulter::RemoveParaAttribs()
{
- SfxItemSet* pCharItems = nullptr;
+ std::unique_ptr<SfxItemSet> pCharItems;
bool bUpdateMode = GetUpdateMode();
if ( bUpdateMode )
SetUpdateMode( false );
@@ -641,7 +641,7 @@ void ScEditEngineDefaulter::RemoveParaAttribs()
if ( !pDefaults || *pParaItem != pDefaults->Get(nWhich) )
{
if (!pCharItems)
- pCharItems = new SfxItemSet( GetEmptyItemSet() );
+ pCharItems.reset(new SfxItemSet( GetEmptyItemSet() ));
pCharItems->Put( *pParaItem );
}
}
@@ -679,7 +679,7 @@ void ScEditEngineDefaulter::RemoveParaAttribs()
nStart = nEnd;
}
- DELETEZ( pCharItems );
+ pCharItems.reset();
}
if ( rParaAttribs.Count() )
diff --git a/sc/source/ui/app/inputhdl.cxx b/sc/source/ui/app/inputhdl.cxx
index aabcc77ec6a4..622967c15fcf 100644
--- a/sc/source/ui/app/inputhdl.cxx
+++ b/sc/source/ui/app/inputhdl.cxx
@@ -2747,7 +2747,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
// Find common (cell) attributes before RemoveAdjust
if ( pActiveViewSh && bUniformAttribs )
{
- SfxItemSet* pCommonAttrs = nullptr;
+ std::unique_ptr<SfxItemSet> pCommonAttrs;
for (sal_uInt16 nId = EE_CHAR_START; nId <= EE_CHAR_END; nId++)
{
SfxItemState eState = aOldAttribs.GetItemState( nId, false, &pItem );
@@ -2757,7 +2757,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
*pItem != pEditDefaults->Get(nId) )
{
if ( !pCommonAttrs )
- pCommonAttrs = new SfxItemSet( mpEditEngine->GetEmptyItemSet() );
+ pCommonAttrs.reset(new SfxItemSet( mpEditEngine->GetEmptyItemSet() ));
pCommonAttrs->Put( *pItem );
}
}
@@ -2766,8 +2766,7 @@ void ScInputHandler::EnterHandler( ScEnterMode nBlockMode )
{
ScDocument* pDoc = pActiveViewSh->GetViewData().GetDocument();
pCellAttrs = o3tl::make_unique<ScPatternAttr>(pDoc->GetPool());
- pCellAttrs->GetFromEditItemSet( pCommonAttrs );
- delete pCommonAttrs;
+ pCellAttrs->GetFromEditItemSet( pCommonAttrs.get() );
}
}
diff --git a/sc/source/ui/docshell/docsh5.cxx b/sc/source/ui/docshell/docsh5.cxx
index 54dbfbd115a6..3fdd844cca2f 100644
--- a/sc/source/ui/docshell/docsh5.cxx
+++ b/sc/source/ui/docshell/docsh5.cxx
@@ -992,10 +992,10 @@ bool ScDocShell::MoveTable( SCTAB nSrcTab, SCTAB nDestTab, bool bCopy, bool bRec
return true; // nothing to do, but valid
}
- ScProgress* pProgress = new ScProgress(this, ScResId(STR_UNDO_MOVE_TAB),
- m_aDocument.GetCodeCount(), true);
- bool bDone = m_aDocument.MoveTab( nSrcTab, nDestTab, pProgress );
- delete pProgress;
+ std::unique_ptr<ScProgress> pProgress(new ScProgress(this, ScResId(STR_UNDO_MOVE_TAB),
+ m_aDocument.GetCodeCount(), true));
+ bool bDone = m_aDocument.MoveTab( nSrcTab, nDestTab, pProgress.get() );
+ pProgress.reset();
if (!bDone)
{
return false;
More information about the Libreoffice-commits
mailing list