summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-08-01 18:14:21 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2016-08-02 01:44:12 +0000
commit389b08190092f9a9103b3ac098994ec83b2d0bfa (patch)
treec7bc32223a7b667e044c9d17f8f831b16eb5eb36 /starmath
parenta859c37ee0126e0daca711893da1cbf6138ec25b (diff)
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>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/node.hxx7
-rw-r--r--starmath/source/mathmlexport.cxx11
-rw-r--r--starmath/source/mathmlexport.hxx2
-rw-r--r--starmath/source/node.cxx6
-rw-r--r--starmath/source/visitors.cxx8
5 files changed, 17 insertions, 17 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 3511d71f395a..a2b50d7d0127 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -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
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index cb1ed0eec4c5..6abd5be7f198 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -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);
diff --git a/starmath/source/mathmlexport.hxx b/starmath/source/mathmlexport.hxx
index 791efa6deaaa..2d18648ffa1e 100644
--- a/starmath/source/mathmlexport.hxx
+++ b/starmath/source/mathmlexport.hxx
@@ -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);
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 34c3480962bc..e6a47267791d 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -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);
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index 7efec06a4937..87d177bcce1f 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -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 );