summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2019-01-17 16:47:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2019-01-18 07:49:38 +0100
commita7fea048dddab17989eaf1097d400aa5bfadf78f (patch)
tree7e09492e0e150a2e650029359ebe44106c9df8bb /starmath
parenta7ea04397bf8c6749c84fe8f0d9afc80e4cf6bb2 (diff)
use unique_ptr in starmath
Change-Id: Ib9c555507d5271343424686f2321ae13efcbf41a Reviewed-on: https://gerrit.libreoffice.org/66550 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/accessibility.cxx12
-rw-r--r--starmath/source/cursor.cxx6
-rw-r--r--starmath/source/mathmlexport.cxx10
3 files changed, 13 insertions, 15 deletions
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;
}
}
}