starmath: SmVerticalBraceNode always has a triple of nodes

Moreover the middle ("Brace") node is a SmMathSymbolNode.

Change-Id: Ia0e4f798b69a9a205269bbd3f6c63d2059e8c766
Reviewed-on: https://gerrit.libreoffice.org/27769
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
This commit is contained in:
Takeshi Abe
2016-08-01 18:14:21 +09:00
parent a859c37ee0
commit 389b081900
5 changed files with 17 additions and 17 deletions

View File

@@ -1369,7 +1369,7 @@ inline const SmMathSymbolNode* SmBraceNode::ClosingBrace() const
inline SmNode* SmVerticalBraceNode::Body()
{
OSL_ASSERT( GetNumSubNodes() > 0 );
assert( GetNumSubNodes() == 3 );
return GetSubNode( 0 );
}
inline const SmNode* SmVerticalBraceNode::Body() const
@@ -1378,7 +1378,8 @@ inline const SmNode* SmVerticalBraceNode::Body() const
}
inline SmMathSymbolNode* SmVerticalBraceNode::Brace()
{
OSL_ASSERT( GetNumSubNodes() > 1 && GetSubNode( 1 )->GetType() == NMATH );
assert( GetNumSubNodes() == 3 );
assert( GetSubNode( 1 )->GetType() == NMATH );
return static_cast< SmMathSymbolNode* >( GetSubNode( 1 ));
}
inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const
@@ -1387,7 +1388,7 @@ inline const SmMathSymbolNode* SmVerticalBraceNode::Brace() const
}
inline SmNode* SmVerticalBraceNode::Script()
{
OSL_ASSERT( GetNumSubNodes() > 2 );
assert( GetNumSubNodes() == 3 );
return GetSubNode( 2 );
}
inline const SmNode* SmVerticalBraceNode::Script() const

View File

@@ -1391,7 +1391,7 @@ void SmXMLExport::ExportFont(const SmNode *pNode, int nLevel)
}
void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
void SmXMLExport::ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel)
{
// "[body] overbrace [script]"
@@ -1417,18 +1417,17 @@ void SmXMLExport::ExportVerticalBrace(const SmNode *pNode, int nLevel)
break;
}
OSL_ENSURE(pNode->GetNumSubNodes()==3,"Bad Vertical Brace");
SvXMLElementExport aOver1(*this, XML_NAMESPACE_MATH,which, true, true);
{//Scoping
// using accents will draw the over-/underbraces too close to the base
// see http://www.w3.org/TR/MathML2/chapter3.html#id.3.4.5.2
// also XML_ACCENT is illegal with XML_MUNDER. Thus no XML_ACCENT attribute here!
SvXMLElementExport aOver2(*this, XML_NAMESPACE_MATH,which, true, true);
ExportNodes(pNode->GetSubNode(0), nLevel);
ExportNodes(pNode->Body(), nLevel);
AddAttribute(XML_NAMESPACE_MATH, XML_STRETCHY, XML_TRUE);
ExportNodes(pNode->GetSubNode(1), nLevel);
ExportNodes(pNode->Brace(), nLevel);
}
ExportNodes(pNode->GetSubNode(2), nLevel);
ExportNodes(pNode->Script(), nLevel);
}
void SmXMLExport::ExportMatrix(const SmNode *pNode, int nLevel)
@@ -1554,7 +1553,7 @@ void SmXMLExport::ExportNodes(const SmNode *pNode, int nLevel)
ExportFont(pNode, nLevel);
break;
case NVERTICAL_BRACE:
ExportVerticalBrace(pNode, nLevel);
ExportVerticalBrace(static_cast<const SmVerticalBraceNode *>(pNode), nLevel);
break;
case NMATRIX:
ExportMatrix(pNode, nLevel);

View File

@@ -89,7 +89,7 @@ protected:
void ExportOperator(const SmNode *pNode, int nLevel);
void ExportAttributes(const SmNode *pNode, int nLevel);
void ExportFont(const SmNode *pNode, int nLevel);
void ExportVerticalBrace(const SmNode *pNode, int nLevel);
void ExportVerticalBrace(const SmVerticalBraceNode *pNode, int nLevel);
void ExportMatrix(const SmNode *pNode, int nLevel);
void ExportBlank(const SmNode *pNode, int nLevel);

View File

@@ -1555,9 +1555,9 @@ void SmBracebodyNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
void SmVerticalBraceNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
{
SmNode *pBody = GetSubNode(0),
*pBrace = GetSubNode(1),
*pScript = GetSubNode(2);
SmNode *pBody = Body(),
*pBrace = Brace(),
*pScript = Script();
assert(pBody);
assert(pBrace);
assert(pScript);

View File

@@ -1181,8 +1181,8 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmBinVerNode* pNode )
*/
void SmCaretPosGraphBuildingVisitor::Visit( SmVerticalBraceNode* pNode )
{
SmNode *pBody = pNode->GetSubNode( 0 ),
*pScript = pNode->GetSubNode( 2 );
SmNode *pBody = pNode->Body(),
*pScript = pNode->Script();
//None of these children can be NULL
SmCaretPosGraphEntry *left,
@@ -2396,8 +2396,8 @@ void SmNodeToTextVisitor::Visit( SmRectangleNode* )
void SmNodeToTextVisitor::Visit( SmVerticalBraceNode* pNode )
{
SmNode *pBody = pNode->GetSubNode( 0 ),
*pScript = pNode->GetSubNode( 2 );
SmNode *pBody = pNode->Body(),
*pScript = pNode->Script();
LineToText( pBody );
Append( pNode->GetToken( ).aText );
LineToText( pScript );