summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-12-21 09:57:46 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-12-21 13:53:17 +0100
commit585328a7136aaa4b98b9cac0355a2cd7e9078dec (patch)
tree28fd94cd6ecaf484de8deec5cb404149666e1654 /starmath
parent10e73684468a811acae56dfeafc8ecb5876a7960 (diff)
ofz#4703 Direct-leak
Change-Id: I5f3385d87aa5a48a8df3b6774dd1166cec60ebf8 Reviewed-on: https://gerrit.libreoffice.org/46893 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/node.hxx22
-rw-r--r--starmath/qa/cppunit/test_node.cxx4
-rw-r--r--starmath/qa/cppunit/test_parse.cxx14
-rw-r--r--starmath/source/cursor.cxx13
-rw-r--r--starmath/source/document.cxx8
-rw-r--r--starmath/source/mathmlexport.cxx16
-rw-r--r--starmath/source/mathmlimport.cxx2
-rw-r--r--starmath/source/mathtype.cxx40
-rw-r--r--starmath/source/node.cxx103
-rw-r--r--starmath/source/ooxmlexport.cxx2
-rw-r--r--starmath/source/rtfexport.cxx2
-rw-r--r--starmath/source/visitors.cxx5
12 files changed, 124 insertions, 107 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 0abc3736111a..260eec9e8943 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -122,9 +122,9 @@ public:
*/
virtual bool IsVisible() const = 0;
- virtual sal_uInt16 GetNumSubNodes() const = 0;
- virtual SmNode * GetSubNode(sal_uInt16 nIndex) = 0;
- const SmNode * GetSubNode(sal_uInt16 nIndex) const
+ virtual size_t GetNumSubNodes() const = 0;
+ virtual SmNode * GetSubNode(size_t nIndex) = 0;
+ const SmNode * GetSubNode(size_t nIndex) const
{
return const_cast<SmNode *>(this)->GetSubNode(nIndex);
}
@@ -231,10 +231,10 @@ public:
virtual bool IsVisible() const override;
- virtual sal_uInt16 GetNumSubNodes() const override;
+ virtual size_t GetNumSubNodes() const override;
using SmNode::GetSubNode;
- virtual SmNode * GetSubNode(sal_uInt16 nIndex) override;
+ virtual SmNode * GetSubNode(size_t nIndex) override;
void SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThird = nullptr);
void SetSubNodes(const SmNodeArray &rNodeArray);
@@ -251,9 +251,9 @@ public:
*/
int IndexOfSubNode(SmNode const * pSubNode)
{
- sal_uInt16 nSize = GetNumSubNodes();
- for(sal_uInt16 i = 0; i < nSize; i++)
- if(pSubNode == GetSubNode(i))
+ size_t nSize = GetNumSubNodes();
+ for (size_t i = 0; i < nSize; i++)
+ if (pSubNode == GetSubNode(i))
return i;
return -1;
}
@@ -294,9 +294,9 @@ protected:
public:
virtual bool IsVisible() const override;
- virtual sal_uInt16 GetNumSubNodes() const override;
+ virtual size_t GetNumSubNodes() const override;
using SmNode::GetSubNode;
- virtual SmNode * GetSubNode(sal_uInt16 nIndex) override;
+ virtual SmNode * GetSubNode(size_t nIndex) override;
};
@@ -859,7 +859,7 @@ public:
/** Get super- or subscript
* @remarks this method may return NULL.
*/
- SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode( sal::static_int_cast< sal_uInt16 >(1 + eSubSup) ); };
+ SmNode * GetSubSup(SmSubSup eSubSup) { return GetSubNode(1 + eSubSup); };
const SmNode * GetSubSup(SmSubSup eSubSup) const { return const_cast< SmSubSupNode* >( this )->GetSubSup( eSubSup ); }
/** Set the body */
diff --git a/starmath/qa/cppunit/test_node.cxx b/starmath/qa/cppunit/test_node.cxx
index 0086dfe45fb3..2a35bdffbe4c 100644
--- a/starmath/qa/cppunit/test_node.cxx
+++ b/starmath/qa/cppunit/test_node.cxx
@@ -89,11 +89,11 @@ void NodeTest::testTdf52225()
#define CHECK_GREEK_SYMBOL(text, code, bItalic) do { \
mxDocShell->SetText(text); \
const SmTableNode *pTree= mxDocShell->GetFormulaTree(); \
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pTree->GetNumSubNodes()); \
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pTree->GetNumSubNodes()); \
const SmNode *pLine = pTree->GetSubNode(0); \
CPPUNIT_ASSERT(pLine); \
CPPUNIT_ASSERT_EQUAL(SmNodeType::Line, pLine->GetType()); \
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pLine->GetNumSubNodes()); \
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pLine->GetNumSubNodes()); \
const SmNode *pNode = pLine->GetSubNode(0); \
CPPUNIT_ASSERT(pNode); \
CPPUNIT_ASSERT_EQUAL(SmNodeType::Special, pNode->GetType()); \
diff --git a/starmath/qa/cppunit/test_parse.cxx b/starmath/qa/cppunit/test_parse.cxx
index cd014ab3ad72..c99a80568839 100644
--- a/starmath/qa/cppunit/test_parse.cxx
+++ b/starmath/qa/cppunit/test_parse.cxx
@@ -66,15 +66,15 @@ void ParseTest::tearDown()
void ParseTest::testMinus()
{
std::unique_ptr<SmTableNode> pNode(SmParser().Parse("-1.2"));
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pNode->GetNumSubNodes());
const SmNode *pNode0 = pNode->GetSubNode(0);
CPPUNIT_ASSERT(pNode0);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Line, pNode0->GetType());
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode0->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pNode0->GetNumSubNodes());
const SmNode *pNode00 = pNode0->GetSubNode(0);
CPPUNIT_ASSERT(pNode00);
CPPUNIT_ASSERT_EQUAL(SmNodeType::UnHor, pNode00->GetType());
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pNode00->GetNumSubNodes());
const SmNode *pNode000 = pNode00->GetSubNode(0);
CPPUNIT_ASSERT(pNode000);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Math, pNode000->GetType());
@@ -99,16 +99,16 @@ void ParseTest::testMinus()
void ParseTest::testNospace()
{
std::unique_ptr<SmTableNode> pNode(SmParser().Parse("nospace{ nitalic d {F(x) G(x)} }"));
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pNode->GetNumSubNodes());
const SmNode *pNode0 = pNode->GetSubNode(0);
CPPUNIT_ASSERT(pNode0);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Line, pNode0->GetType());
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(1), pNode0->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(1), pNode0->GetNumSubNodes());
const SmNode *pNode00 = pNode0->GetSubNode(0);
CPPUNIT_ASSERT(pNode00);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Expression, pNode00->GetType());
CPPUNIT_ASSERT(!static_cast<const SmExpressionNode *>(pNode00)->IsUseExtraSpaces());
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pNode00->GetNumSubNodes());
const SmNode *pNode000 = pNode00->GetSubNode(0);
CPPUNIT_ASSERT(pNode000);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Font, pNode000->GetType());
@@ -118,7 +118,7 @@ void ParseTest::testNospace()
CPPUNIT_ASSERT(pNode001);
CPPUNIT_ASSERT_EQUAL(SmNodeType::Expression, pNode001->GetType());
CPPUNIT_ASSERT(static_cast<const SmExpressionNode *>(pNode001)->IsUseExtraSpaces());
- CPPUNIT_ASSERT_EQUAL(sal_uInt16(2), pNode00->GetNumSubNodes());
+ CPPUNIT_ASSERT_EQUAL(size_t(2), pNode00->GetNumSubNodes());
}
CPPUNIT_TEST_SUITE_REGISTRATION(ParseTest);
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx
index 1ffd1c783a55..84c364bc17d6 100644
--- a/starmath/source/cursor.cxx
+++ b/starmath/source/cursor.cxx
@@ -181,11 +181,13 @@ void SmCursor::DeletePrev(OutputDevice* pDev){
SmNode* pLine = FindTopMostNodeInLine(mpPosition->CaretPos.pSelectedNode);
SmStructureNode* pLineParent = pLine->GetParent();
- int nLineOffset = pLineParent->IndexOfSubNode(pLine);
- assert(nLineOffset >= 0);
+ int nLineOffsetIdx = pLineParent->IndexOfSubNode(pLine);
+ assert(nLineOffsetIdx >= 0);
//If we're in front of a node who's parent is a TABLE
- if(pLineParent->GetType() == SmNodeType::Table && mpPosition->CaretPos.nIndex == 0 && nLineOffset > 0){
+ if (pLineParent->GetType() == SmNodeType::Table && mpPosition->CaretPos.nIndex == 0 && nLineOffsetIdx > 0)
+ {
+ size_t nLineOffset = nLineOffsetIdx;
//Now we can merge with nLineOffset - 1
BeginEdit();
//Line to merge things into, so we can delete pLine
@@ -210,7 +212,8 @@ void SmCursor::DeletePrev(OutputDevice* pDev){
pLineParent->SetSubNode(nLineOffset-1, pLine);
//Delete the removed line slot
SmNodeArray lines(pLineParent->GetNumSubNodes()-1);
- for(int i = 0; i < pLineParent->GetNumSubNodes(); i++){
+ for (size_t i = 0; i < pLineParent->GetNumSubNodes(); ++i)
+ {
if(i < nLineOffset)
lines[i] = pLineParent->GetSubNode(i);
else if(i > nLineOffset)
@@ -1353,7 +1356,7 @@ bool SmCursor::IsAtTailOfBracket(SmBracketType eBracketType, SmBraceNode** ppBra
int index = pParentNode->IndexOfSubNode(pNode);
assert(index >= 0);
- if (index + 1 != pParentNode->GetNumSubNodes()) {
+ if (static_cast<size_t>(index + 1) != pParentNode->GetNumSubNodes()) {
// The cursor is not at the tail at one of ancestor nodes.
return false;
}
diff --git a/starmath/source/document.cxx b/starmath/source/document.cxx
index d59b5ae69641..9466d6635674 100644
--- a/starmath/source/document.cxx
+++ b/starmath/source/document.cxx
@@ -1047,7 +1047,7 @@ void SmDocShell::Execute(SfxRequest& rReq)
bool (::svl::IUndoManager:: *fnDo)();
- std::size_t nCount;
+ size_t nCount;
if( SID_UNDO == rReq.GetSlot() )
{
nCount = pTmpUndoMgr->GetUndoActionCount();
@@ -1154,7 +1154,7 @@ void SmDocShell::GetState(SfxItemSet &rSet)
{
OUString(::svl::IUndoManager:: *fnGetComment)( size_t, bool const ) const;
- sal_uInt16 nCount;
+ size_t nCount;
if( SID_GETUNDOSTRINGS == nWh )
{
nCount = pTmpUndoMgr->GetUndoActionCount();
@@ -1165,10 +1165,10 @@ void SmDocShell::GetState(SfxItemSet &rSet)
nCount = pTmpUndoMgr->GetRedoActionCount();
fnGetComment = &::svl::IUndoManager::GetRedoActionComment;
}
- if( nCount )
+ if (nCount)
{
OUStringBuffer aBuf;
- for( sal_uInt16 n = 0; n < nCount; ++n )
+ for (size_t n = 0; n < nCount; ++n)
{
aBuf.append((pTmpUndoMgr->*fnGetComment)( n, ::svl::IUndoManager::TopLevel ));
aBuf.append('\n');
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index 86b8ae5806b4..780bf226c6ef 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -629,16 +629,18 @@ void SmXMLExport::ExportExpression(const SmNode *pNode, int nLevel,
bool bNoMrowContainer /*=false*/)
{
SvXMLElementExport *pRow=nullptr;
- auto nSize = pNode->GetNumSubNodes();
+ size_t nSize = pNode->GetNumSubNodes();
// #i115443: nodes of type expression always need to be grouped with mrow statement
if (!bNoMrowContainer &&
(nSize > 1 || pNode->GetType() == SmNodeType::Expression))
pRow = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MROW, true, true);
- for (sal_uInt16 i = 0; i < nSize; i++)
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (const SmNode *pTemp = pNode->GetSubNode(i))
ExportNodes(pTemp, nLevel+1);
+ }
delete pRow;
}
@@ -705,7 +707,7 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
{
SvXMLElementExport *pTable=nullptr;
- sal_uInt16 nSize = pNode->GetNumSubNodes();
+ size_t nSize = pNode->GetNumSubNodes();
//If the list ends in newline then the last entry has
//no subnodes, the newline is superfluous so we just drop
@@ -725,7 +727,8 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
if (nLevel || (nSize >1))
pTable = new SvXMLElementExport(*this, XML_NAMESPACE_MATH, XML_MTABLE, true, true);
- for (sal_uInt16 i = 0; i < nSize; i++)
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (const SmNode *pTemp = pNode->GetSubNode(i))
{
SvXMLElementExport *pRow=nullptr;
@@ -765,6 +768,7 @@ void SmXMLExport::ExportTable(const SmNode *pNode, int nLevel)
delete pCell;
delete pRow;
}
+ }
delete pTable;
}
@@ -1409,11 +1413,12 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
{
SvXMLElementExport aTable(*this, XML_NAMESPACE_MATH, XML_MTABLE, true, true);
const SmMatrixNode *pMatrix = static_cast<const SmMatrixNode *>(pNode);
- sal_uInt16 i=0;
+ size_t i = 0;
for (sal_uInt16 y = 0; y < pMatrix->GetNumRows(); y++)
{
SvXMLElementExport aRow(*this, XML_NAMESPACE_MATH, XML_MTR, true, true);
for (sal_uInt16 x = 0; x < pMatrix->GetNumCols(); x++)
+ {
if (const SmNode *pTemp = pNode->GetSubNode(i++))
{
if (pTemp->GetType() == SmNodeType::Align &&
@@ -1428,6 +1433,7 @@ void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
SvXMLElementExport aCell(*this, XML_NAMESPACE_MATH, XML_MTD, true, true);
ExportNodes(pTemp, nLevel+1);
}
+ }
}
}
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 7d1d63756d62..270388d0258b 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -2682,7 +2682,7 @@ void SmXMLTableContext_Impl::EndElement()
{
std::unique_ptr<SmStructureNode> xArray(static_cast<SmStructureNode*>(aReverseStack.front().release()));
aReverseStack.pop_front();
- for (sal_uInt16 i = 0; i < xArray->GetNumSubNodes(); ++i)
+ for (size_t i = 0; i < xArray->GetNumSubNodes(); ++i)
aExpressionArray[j++] = xArray->GetSubNode(i);
xArray->SetSubNodes(SmNodeArray());
}
diff --git a/starmath/source/mathtype.cxx b/starmath/source/mathtype.cxx
index 9c726cc67c08..da040887adc2 100644
--- a/starmath/source/mathtype.cxx
+++ b/starmath/source/mathtype.cxx
@@ -2000,13 +2000,15 @@ void MathType::HandleNodes(SmNode *pNode,int nLevel)
HandleSubSupScript(pNode,nLevel);
break;
case SmNodeType::Expression:
+ {
+ size_t nSize = pNode->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
{
- sal_uInt16 nSize = pNode->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++)
if (SmNode *pTemp = pNode->GetSubNode(i))
HandleNodes(pTemp,nLevel+1);
}
break;
+ }
case SmNodeType::Table:
//Root Node, PILE equivalent, i.e. vertical stack
HandleTable(pNode,nLevel);
@@ -2015,16 +2017,18 @@ void MathType::HandleNodes(SmNode *pNode,int nLevel)
HandleSmMatrix(static_cast<SmMatrixNode *>(pNode),nLevel);
break;
case SmNodeType::Line:
- {
+ {
pS->WriteUChar( 0x0a );
pS->WriteUChar( LINE );
- sal_uInt16 nSize = pNode->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++)
+ size_t nSize = pNode->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (SmNode *pTemp = pNode->GetSubNode(i))
HandleNodes(pTemp,nLevel+1);
- pS->WriteUChar( END );
}
+ pS->WriteUChar( END );
break;
+ }
case SmNodeType::Align:
HandleMAlign(pNode,nLevel);
break;
@@ -2037,13 +2041,15 @@ void MathType::HandleNodes(SmNode *pNode,int nLevel)
pS->WriteUInt16( 0xEB05 );
break;
default:
+ {
+ size_t nSize = pNode->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
{
- sal_uInt16 nSize = pNode->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++)
if (SmNode *pTemp = pNode->GetSubNode(i))
HandleNodes(pTemp,nLevel+1);
}
break;
+ }
}
}
@@ -2091,14 +2097,16 @@ void MathType::HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel)
nBytes++;
for (int k = 0; k < nBytes; k++)
pS->WriteUChar( 0x00 ); //col_parts
- sal_uInt16 nSize = pMatrix->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++)
+ size_t nSize = pMatrix->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (SmNode *pTemp = pMatrix->GetSubNode(i))
{
pS->WriteUChar( LINE ); //line
HandleNodes(pTemp,nLevel+1);
pS->WriteUChar( END ); //end line
}
+ }
pS->WriteUChar( END );
}
@@ -2106,7 +2114,7 @@ void MathType::HandleSmMatrix(SmMatrixNode *pMatrix,int nLevel)
//Root Node, PILE equivalent, i.e. vertical stack
void MathType::HandleTable(SmNode *pNode,int nLevel)
{
- sal_uInt16 nSize = pNode->GetNumSubNodes();
+ size_t nSize = pNode->GetNumSubNodes();
//The root of the starmath is a table, if
//we convert this them each iteration of
//conversion from starmath to mathtype will
@@ -2124,13 +2132,15 @@ void MathType::HandleTable(SmNode *pNode,int nLevel)
pS->WriteUChar( 0x01 ); //hAlign
}
- for (sal_uInt16 i = 0; i < nSize; i++)
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (SmNode *pTemp = pNode->GetSubNode(i))
{
pS->WriteUChar( LINE );
HandleNodes(pTemp,nLevel+1);
pS->WriteUChar( END );
}
+ }
if (nLevel || (nSize>1))
pS->WriteUChar( END );
}
@@ -3049,10 +3059,12 @@ void MathType::HandleMAlign(SmNode *pNode,int nLevel)
nHAlign=1;
break;
}
- sal_uInt16 nSize = pNode->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++)
+ size_t nSize = pNode->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (SmNode *pTemp = pNode->GetSubNode(i))
HandleNodes(pTemp,nLevel+1);
+ }
nHAlign=nPushedHAlign;
}
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 39195f5ba194..4839248940de 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -44,8 +44,9 @@ namespace {
template<typename F>
void ForEachNonNull(SmNode *pNode, F && f)
{
- sal_uInt16 nSize = pNode->GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nSize; i++) {
+ size_t nSize = pNode->GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
+ {
SmNode *pSubNode = pNode->GetSubNode(i);
if (pSubNode != nullptr)
f(pSubNode);
@@ -68,12 +69,10 @@ SmNode::SmNode(SmNodeType eNodeType, const SmToken &rNodeToken)
{
}
-
SmNode::~SmNode()
{
}
-
const SmNode * SmNode::GetLeftMost() const
// returns leftmost node of current subtree.
//! (this assumes the one with index 0 is always the leftmost subnode
@@ -249,10 +248,9 @@ void SmNode::Move(const Point& rPosition)
ForEachNonNull(this, [&rPosition](SmNode *pNode){pNode->Move(rPosition);});
}
-
void SmNode::CreateTextFromNode(OUString &rText)
{
- sal_uInt16 nSize = GetNumSubNodes();
+ auto nSize = GetNumSubNodes();
if (nSize > 1)
rText += "{";
ForEachNonNull(this, [&rText](SmNode *pNode){pNode->CreateTextFromNode(rText);});
@@ -263,7 +261,6 @@ void SmNode::CreateTextFromNode(OUString &rText)
}
}
-
void SmNode::AdaptToX(OutputDevice &/*rDev*/, sal_uLong /*nWidth*/)
{
}
@@ -285,9 +282,10 @@ const SmNode * SmNode::FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const
return this;
else
{
- sal_uInt16 nNumSubNodes = GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nNumSubNodes; i++)
- { const SmNode *pNode = GetSubNode(i);
+ size_t nNumSubNodes = GetNumSubNodes();
+ for (size_t i = 0; i < nNumSubNodes; ++i)
+ {
+ const SmNode *pNode = GetSubNode(i);
if (!pNode)
continue;
@@ -311,9 +309,10 @@ const SmNode * SmNode::FindRectClosestTo(const Point &rPoint) const
pResult = this;
else
{
- sal_uInt16 nNumSubNodes = GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nNumSubNodes; i++)
- { const SmNode *pNode = GetSubNode(i);
+ size_t nNumSubNodes = GetNumSubNodes();
+ for (size_t i = 0; i < nNumSubNodes; ++i)
+ {
+ const SmNode *pNode = GetSubNode(i);
if (!pNode)
continue;
@@ -353,8 +352,8 @@ const SmNode * SmNode::FindNodeWithAccessibleIndex(sal_Int32 nAccIdx) const
pResult = this;
else
{
- sal_uInt16 nNumSubNodes = GetNumSubNodes();
- for (sal_uInt16 i = 0; i < nNumSubNodes; i++)
+ size_t nNumSubNodes = GetNumSubNodes();
+ for (size_t i = 0; i < nNumSubNodes; ++i)
{
const SmNode *pNode = GetSubNode(i);
if (!pNode)
@@ -390,32 +389,27 @@ void SmStructureNode::SetSubNodes(SmNode *pFirst, SmNode *pSecond, SmNode *pThir
ClaimPaternity();
}
-
void SmStructureNode::SetSubNodes(const SmNodeArray &rNodeArray)
{
maSubNodes = rNodeArray;
ClaimPaternity();
}
-
bool SmStructureNode::IsVisible() const
{
return false;
}
-
-sal_uInt16 SmStructureNode::GetNumSubNodes() const
+size_t SmStructureNode::GetNumSubNodes() const
{
- return sal::static_int_cast<sal_uInt16>(maSubNodes.size());
+ return maSubNodes.size();
}
-
-SmNode * SmStructureNode::GetSubNode(sal_uInt16 nIndex)
+SmNode* SmStructureNode::GetSubNode(size_t nIndex)
{
return maSubNodes[nIndex];
}
-
void SmStructureNode::GetAccessibleText( OUStringBuffer &rText ) const
{
ForEachNonNull(const_cast<SmStructureNode *>(this),
@@ -427,26 +421,22 @@ void SmStructureNode::GetAccessibleText( OUStringBuffer &rText ) const
});
}
-
void SmStructureNode::ClaimPaternity()
{
ForEachNonNull(this, [this](SmNode *pNode){pNode->SetParent(this);});
}
-
bool SmVisibleNode::IsVisible() const
{
return true;
}
-
-sal_uInt16 SmVisibleNode::GetNumSubNodes() const
+size_t SmVisibleNode::GetNumSubNodes() const
{
return 0;
}
-
-SmNode * SmVisibleNode::GetSubNode(sal_uInt16 /*nIndex*/)
+SmNode * SmVisibleNode::GetSubNode(size_t /*nIndex*/)
{
return nullptr;
}
@@ -458,10 +448,10 @@ void SmGraphicNode::GetAccessibleText( OUStringBuffer &rText ) const
void SmExpressionNode::CreateTextFromNode(OUString &rText)
{
- sal_uInt16 nSize = GetNumSubNodes();
+ size_t nSize = GetNumSubNodes();
if (nSize > 1)
rText += "{";
- for (sal_uInt16 i = 0; i < nSize; i++)
+ for (size_t i = 0; i < nSize; ++i)
{
SmNode *pNode = GetSubNode(i);
if (pNode)
@@ -486,7 +476,7 @@ void SmTableNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
// arranges all subnodes in one column
{
SmNode *pNode;
- sal_uInt16 nSize = GetNumSubNodes();
+ size_t nSize = GetNumSubNodes();
// make distance depend on font size
long nDist = +(rFormat.GetDistance(DIS_VERTICAL)
@@ -498,18 +488,20 @@ void SmTableNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
// arrange subnodes and get maximum width of them
long nMaxWidth = 0,
nTmp;
- sal_uInt16 i;
- for (i = 0; i < nSize; i++)
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (nullptr != (pNode = GetSubNode(i)))
{ pNode->Arrange(rDev, rFormat);
if ((nTmp = pNode->GetItalicWidth()) > nMaxWidth)
nMaxWidth = nTmp;
}
+ }
Point aPos;
SmRect::operator = (SmRect(nMaxWidth, 1));
- for (i = 0; i < nSize; i++)
- { if (nullptr != (pNode = GetSubNode(i)))
+ for (size_t i = 0; i < nSize; ++i)
+ {
+ if (nullptr != (pNode = GetSubNode(i)))
{ const SmRect &rNodeRect = pNode->GetRect();
const SmNode *pCoNode = pNode->GetLeftMost();
RectHorAlign eHorAlign = pCoNode->GetRectHorAlign();
@@ -571,11 +563,12 @@ void SmLineNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
// arranges all subnodes in one row with some extra space between
{
SmNode *pNode;
- sal_uInt16 nSize = GetNumSubNodes();
- sal_uInt16 i;
- for (i = 0; i < nSize; i++)
+ size_t nSize = GetNumSubNodes();
+ for (size_t i = 0; i < nSize; ++i)
+ {
if (nullptr != (pNode = GetSubNode(i)))
pNode->Arrange(rDev, rFormat);
+ }
SmTmpDevice aTmpDev (rDev, true);
aTmpDev.SetFont(GetFont());
@@ -606,7 +599,8 @@ void SmLineNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
if (nullptr != (pNode = GetSubNode(0)))
SmRect::operator = (pNode->GetRect());
- for (i = 1; i < nSize; i++)
+ for (size_t i = 1; i < nSize; ++i)
+ {
if (nullptr != (pNode = GetSubNode(i)))
{
aPos = pNode->AlignTo(*this, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
@@ -617,6 +611,7 @@ void SmLineNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
pNode->MoveTo(aPos);
ExtendBy( *pNode, RectCopyMBL::Xor );
}
+ }
}
@@ -1435,18 +1430,17 @@ void SmBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
{
- sal_uInt16 nNumSubNodes = GetNumSubNodes();
+ size_t nNumSubNodes = GetNumSubNodes();
if (nNumSubNodes == 0)
return;
// arrange arguments
- sal_uInt16 i;
- for (i = 0; i < nNumSubNodes; i += 2)
+ for (size_t i = 0; i < nNumSubNodes; i += 2)
GetSubNode(i)->Arrange(rDev, rFormat);
// build reference rectangle with necessary info for vertical alignment
SmRect aRefRect (*GetSubNode(0));
- for (i = 0; i < nNumSubNodes; i += 2)
+ for (size_t i = 0; i < nNumSubNodes; i += 2)
{
SmRect aTmpRect (*GetSubNode(i));
Point aPos = aTmpRect.AlignTo(aRefRect, RectPos::Right, RectHorAlign::Center, RectVerAlign::Baseline);
@@ -1464,7 +1458,7 @@ void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
sal_uInt16 nPerc = rFormat.GetDistance(nIndex);
if (bScale)
nHeight += 2 * (nHeight * nPerc / 100L);
- for (i = 1; i < nNumSubNodes; i += 2)
+ for (size_t i = 1; i < nNumSubNodes; i += 2)
{
SmNode *pNode = GetSubNode(i);
pNode->AdaptToY(rDev, nHeight);
@@ -1477,7 +1471,7 @@ void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
SmNode *pLeft = GetSubNode(0);
SmRect::operator = (*pLeft);
- for (i = 1; i < nNumSubNodes; i++)
+ for (size_t i = 1; i < nNumSubNodes; ++i)
{
bool bIsSeparator = i % 2 != 0;
RectVerAlign eVerAlign = bIsSeparator ? RectVerAlign::CenterY : RectVerAlign::Baseline;
@@ -2231,17 +2225,16 @@ void SmMatrixNode::CreateTextFromNode(OUString &rText)
void SmMatrixNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
{
SmNode *pNode;
- sal_uInt16 i, j;
// initialize array that is to hold the maximum widths of all
// elements (subnodes) in that column.
std::vector<long> aColWidth(mnNumCols);
// arrange subnodes and calculate the above arrays contents
- sal_uInt16 nNodes = GetNumSubNodes();
- for (i = 0; i < nNodes; i++)
+ size_t nNodes = GetNumSubNodes();
+ for (size_t i = 0; i < nNodes; ++i)
{
- sal_uInt16 nIdx = nNodes - 1 - i;
+ size_t nIdx = nNodes - 1 - i;
if (nullptr != (pNode = GetSubNode(nIdx)))
{
pNode->Arrange(rDev, rFormat);
@@ -2261,18 +2254,18 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
// build array that holds the leftmost position for each column
std::vector<long> aColLeft(mnNumCols);
long nX = 0;
- for (j = 0; j < mnNumCols; j++)
+ for (size_t j = 0; j < mnNumCols; ++j)
{
aColLeft[j] = nX;
nX += aColWidth[j] + nHorDist;
}
SmRect::operator = (SmRect());
- for (i = 0; i < mnNumRows; i++)
+ for (size_t i = 0; i < mnNumRows; ++i)
{
Point aPos;
SmRect aLineRect;
- for (j = 0; j < mnNumCols; j++)
+ for (size_t j = 0; j < mnNumCols; ++j)
{
SmNode *pTmpNode = GetSubNode(i * mnNumCols + j);
assert(pTmpNode);
@@ -2317,9 +2310,11 @@ void SmMatrixNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
Point aDelta(0, // since horizontal alignment is already done
aPos.Y() - aLineRect.GetTop());
aLineRect.Move(aDelta);
- for (j = 0; j < mnNumCols; j++)
+ for (size_t j = 0; j < mnNumCols; ++j)
+ {
if (nullptr != (pNode = GetSubNode(i * mnNumCols + j)))
pNode->Move(aDelta);
+ }
ExtendBy(aLineRect, RectCopyMBL::None);
}
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 39b47a6d990b..29cd46e9bea2 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -470,7 +470,7 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel )
{
const SmBracebodyNode* body = static_cast< const SmBracebodyNode* >( pNode->Body());
bool separatorWritten = false; // assume all separators are the same
- for( int i = 0; i < body->GetNumSubNodes(); ++i )
+ for (size_t i = 0; i < body->GetNumSubNodes(); ++i)
{
const SmNode* subnode = body->GetSubNode( i );
if (subnode->GetType() == SmNodeType::Math || subnode->GetType() == SmNodeType::MathIdent)
diff --git a/starmath/source/rtfexport.cxx b/starmath/source/rtfexport.cxx
index 0d0fb4cae6c8..a06bb4c5a4ad 100644
--- a/starmath/source/rtfexport.cxx
+++ b/starmath/source/rtfexport.cxx
@@ -412,7 +412,7 @@ void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
{
auto body = static_cast<const SmBracebodyNode*>(pNode->Body());
bool separatorWritten = false; // assume all separators are the same
- for (int i = 0; i < body->GetNumSubNodes(); ++i)
+ for (size_t i = 0; i < body->GetNumSubNodes(); ++i)
{
const SmNode* subnode = body->GetSubNode(i);
if (subnode->GetType() == SmNodeType::Math
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 91e0e3a62de0..207e274680c4 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1613,11 +1613,12 @@ void SmCloningVisitor::CloneKids( SmStructureNode* pSource, SmStructureNode* pTa
SmNode* pCurrResult = mpResult;
//Create array for holding clones
- sal_uInt16 nSize = pSource->GetNumSubNodes( );
+ size_t nSize = pSource->GetNumSubNodes( );
SmNodeArray aNodes( nSize );
//Clone children
- for( sal_uInt16 i = 0; i < nSize; i++ ){
+ for (size_t i = 0; i < nSize; ++i)
+ {
SmNode* pKid;
if( nullptr != ( pKid = pSource->GetSubNode( i ) ) )
pKid->Accept( this );