summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-08-08 14:36:15 +0900
committerCaolán McNamara <caolanm@redhat.com>2016-08-08 11:41:25 +0000
commit450a8ee1f49ca32184103a7ddc579351cfc24a6d (patch)
tree21c142f91419d425349525e7ad161b2dd50d8555 /starmath
parentf60eaab748add19683e66c7e4bc073c9ce7887f7 (diff)
starmath: SmBraceNode always has 3 children
Change-Id: I53ef8c215866fc45ee82b6805c41c93da0e024b7 Reviewed-on: https://gerrit.libreoffice.org/27980 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.hxx8
-rw-r--r--starmath/source/node.cxx12
-rw-r--r--starmath/source/ooxmlexport.cxx4
-rw-r--r--starmath/source/visitors.cxx8
4 files changed, 17 insertions, 15 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index a57922175b94..1e61304281c4 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -1342,7 +1342,8 @@ inline const SmNode* SmAttributNode::Body() const
inline SmMathSymbolNode* SmBraceNode::OpeningBrace()
{
- OSL_ASSERT( GetNumSubNodes() > 0 && GetSubNode( 0 )->GetType() == NMATH );
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 0 )->GetType() == NMATH );
return static_cast< SmMathSymbolNode* >( GetSubNode( 0 ));
}
inline const SmMathSymbolNode* SmBraceNode::OpeningBrace() const
@@ -1351,7 +1352,7 @@ inline const SmMathSymbolNode* SmBraceNode::OpeningBrace() const
}
inline SmNode* SmBraceNode::Body()
{
- OSL_ASSERT( GetNumSubNodes() > 1 );
+ assert( GetNumSubNodes() == 3 );
return GetSubNode( 1 );
}
inline const SmNode* SmBraceNode::Body() const
@@ -1360,7 +1361,8 @@ inline const SmNode* SmBraceNode::Body() const
}
inline SmMathSymbolNode* SmBraceNode::ClosingBrace()
{
- OSL_ASSERT( GetNumSubNodes() > 2 && GetSubNode( 2 )->GetType() == NMATH );
+ assert( GetNumSubNodes() == 3 );
+ assert( GetSubNode( 2 )->GetType() == NMATH );
return static_cast< SmMathSymbolNode* >( GetSubNode( 2 ));
}
inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index d5e4a45447c3..511db4305792 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -1350,7 +1350,7 @@ void SmBraceNode::CreateTextFromNode(OUString &rText)
rText += "left ";
{
OUString aStr;
- GetSubNode(0)->CreateTextFromNode(aStr);
+ OpeningBrace()->CreateTextFromNode(aStr);
aStr = comphelper::string::strip(aStr, ' ');
aStr = comphelper::string::stripStart(aStr, '\\');
if (!aStr.isEmpty())
@@ -1368,12 +1368,12 @@ void SmBraceNode::CreateTextFromNode(OUString &rText)
else
rText += "none ";
}
- GetSubNode(1)->CreateTextFromNode(rText);
+ Body()->CreateTextFromNode(rText);
if (GetScaleMode() == SCALE_HEIGHT)
rText += "right ";
{
OUString aStr;
- GetSubNode(2)->CreateTextFromNode(aStr);
+ ClosingBrace()->CreateTextFromNode(aStr);
aStr = comphelper::string::strip(aStr, ' ');
aStr = comphelper::string::stripStart(aStr, '\\');
if (!aStr.isEmpty())
@@ -1397,9 +1397,9 @@ void SmBraceNode::CreateTextFromNode(OUString &rText)
void SmBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
{
- SmNode *pLeft = GetSubNode(0),
- *pBody = GetSubNode(1),
- *pRight = GetSubNode(2);
+ SmNode *pLeft = OpeningBrace(),
+ *pBody = Body(),
+ *pRight = ClosingBrace();
assert(pLeft);
assert(pBody);
assert(pRight);
diff --git a/starmath/source/ooxmlexport.cxx b/starmath/source/ooxmlexport.cxx
index 1e79e681c742..b387bd649716 100644
--- a/starmath/source/ooxmlexport.cxx
+++ b/starmath/source/ooxmlexport.cxx
@@ -458,7 +458,7 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel )
m_pSerializer->startElementNS( XML_m, XML_dPr, FSEND );
//check if the node has an opening brace
- if( TNONE == pNode->GetSubNode(0)->GetToken().eType )
+ if( TNONE == pNode->OpeningBrace()->GetToken().eType )
m_pSerializer->singleElementNS( XML_m, XML_begChr,
FSNS( XML_m, XML_val ), "", FSEND );
else
@@ -490,7 +490,7 @@ void SmOoxmlExport::HandleBrace( const SmBraceNode* pNode, int nLevel )
else
subnodes.push_back( pNode->Body());
- if( TNONE == pNode->GetSubNode(2)->GetToken().eType )
+ if( TNONE == pNode->ClosingBrace()->GetToken().eType )
m_pSerializer->singleElementNS( XML_m, XML_endChr,
FSNS( XML_m, XML_val ), "", FSEND );
else
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 7e11f083e69c..e3f9c0b266b8 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1499,7 +1499,7 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmBlankNode* pNode )
*/
void SmCaretPosGraphBuildingVisitor::Visit( SmBraceNode* pNode )
{
- SmNode* pBody = pNode->GetSubNode( 1 );
+ SmNode* pBody = pNode->Body();
SmCaretPosGraphEntry *left = mpRightMost,
*right = mpGraph->Add( SmCaretPos( pNode, 1 ) );
@@ -1988,9 +1988,9 @@ void SmNodeToTextVisitor::Visit( SmTableNode* pNode )
void SmNodeToTextVisitor::Visit( SmBraceNode* pNode )
{
- SmNode *pLeftBrace = pNode->GetSubNode( 0 ),
- *pBody = pNode->GetSubNode( 1 ),
- *pRightBrace = pNode->GetSubNode( 2 );
+ SmNode *pLeftBrace = pNode->OpeningBrace(),
+ *pBody = pNode->Body(),
+ *pRightBrace = pNode->ClosingBrace();
//Handle special case where it's absolute function
if( pNode->GetToken( ).eType == TABS ) {
Append( "abs" );