summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@fixedpoint.jp>2016-08-05 23:32:49 +0900
committerTakeshi Abe <tabe@fixedpoint.jp>2016-08-07 03:36:37 +0000
commitdd612a61f9df81343ed5f810068002a7a25046a7 (patch)
tree84c4271d5a4d469b73be2fb00467625516a4fb9a /starmath
parent05c89af876fc7bb2e02e7de84df0cfc2869b0071 (diff)
starmath: complete SmAttributNode has just 2 subnodes
Change-Id: Ifbecef188b314d599d7e97717934143b2aac8c09 Reviewed-on: https://gerrit.libreoffice.org/27912 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Takeshi Abe <tabe@fixedpoint.jp>
Diffstat (limited to 'starmath')
-rw-r--r--starmath/inc/node.hxx6
-rw-r--r--starmath/source/mathmlimport.cxx21
-rw-r--r--starmath/source/node.cxx14
-rw-r--r--starmath/source/parse.cxx2
-rw-r--r--starmath/source/visitors.cxx9
5 files changed, 23 insertions, 29 deletions
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index e0b2019d433a..a57922175b94 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -1145,7 +1145,7 @@ class SmAttributNode : public SmStructureNode
{
public:
explicit SmAttributNode(const SmToken &rNodeToken)
- : SmStructureNode(NATTRIBUT, rNodeToken)
+ : SmStructureNode(NATTRIBUT, rNodeToken, 2)
{}
virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
@@ -1323,7 +1323,7 @@ inline const SmNode* SmBinHorNode::RightOperand() const
inline SmNode* SmAttributNode::Attribute()
{
- OSL_ASSERT( GetNumSubNodes() > 0 );
+ assert( GetNumSubNodes() == 2 );
return GetSubNode( 0 );
}
inline const SmNode* SmAttributNode::Attribute() const
@@ -1332,7 +1332,7 @@ inline const SmNode* SmAttributNode::Attribute() const
}
inline SmNode* SmAttributNode::Body()
{
- OSL_ASSERT( GetNumSubNodes() > 1 );
+ assert( GetNumSubNodes() == 2 );
return GetSubNode( 1 );
}
inline const SmNode* SmAttributNode::Body() const
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 03accbf79cff..8946c6f5a59f 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -1488,21 +1488,18 @@ void SmXMLUnderContext_Impl::HandleAccent()
aToken.cMathChar = '\0';
aToken.eType = TUNDERLINE;
-
- SmNodeArray aSubNodes;
- aSubNodes.resize(2);
-
+ SmNode *pFirst;
std::unique_ptr<SmStructureNode> pNode(new SmAttributNode(aToken));
if ((pTest->GetToken().cMathChar & 0x0FFF) == 0x0332)
{
- aSubNodes[0] = new SmRectangleNode(aToken);
+ pFirst = new SmRectangleNode(aToken);
delete pTest;
}
else
- aSubNodes[0] = pTest;
+ pFirst = pTest;
- aSubNodes[1] = popOrZero(rNodeStack);
- pNode->SetSubNodes(aSubNodes);
+ SmNode *pSecond = popOrZero(rNodeStack);
+ pNode->SetSubNodes(pFirst, pSecond);
pNode->SetScaleMode(SCALE_WIDTH);
rNodeStack.push_front(std::move(pNode));
}
@@ -1563,11 +1560,9 @@ void SmXMLOverContext_Impl::HandleAccent()
std::unique_ptr<SmAttributNode> pNode(new SmAttributNode(aToken));
SmNodeStack &rNodeStack = GetSmImport().GetNodeStack();
- SmNodeArray aSubNodes;
- aSubNodes.resize(2);
- aSubNodes[0] = popOrZero(rNodeStack);
- aSubNodes[1] = popOrZero(rNodeStack);
- pNode->SetSubNodes(aSubNodes);
+ SmNode *pFirst = popOrZero(rNodeStack);
+ SmNode *pSecond = popOrZero(rNodeStack);
+ pNode->SetSubNodes(pFirst, pSecond);
pNode->SetScaleMode(SCALE_WIDTH);
rNodeStack.push_front(std::move(pNode));
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 5b45745a0474..d5e4a45447c3 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -1724,8 +1724,8 @@ void SmAlignNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
void SmAttributNode::Arrange(OutputDevice &rDev, const SmFormat &rFormat)
{
- SmNode *pAttr = GetSubNode(0),
- *pBody = GetSubNode(1);
+ SmNode *pAttr = Attribute(),
+ *pBody = Body();
assert(pBody);
assert(pAttr);
@@ -2534,11 +2534,10 @@ void SmRectangleNode::CreateTextFromNode(OUString &rText)
void SmAttributNode::CreateTextFromNode(OUString &rText)
{
SmNode *pNode;
- sal_uInt16 nSize = GetNumSubNodes();
- OSL_ENSURE(nSize == 2, "Node missing members");
+ assert(GetNumSubNodes() == 2);
rText += "{";
sal_Unicode nLast=0;
- if (nullptr != (pNode = GetSubNode(0)))
+ if (nullptr != (pNode = Attribute()))
{
OUString aStr;
pNode->CreateTextFromNode(aStr);
@@ -2609,9 +2608,8 @@ void SmAttributNode::CreateTextFromNode(OUString &rText)
}
}
- if (nSize == 2)
- if (nullptr != (pNode = GetSubNode(1)))
- pNode->CreateTextFromNode(rText);
+ if (nullptr != (pNode = Body()))
+ pNode->CreateTextFromNode(rText);
rText = comphelper::string::stripEnd(rText, ' ');
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 9ac2d932e748..1e11be32fa91 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -1772,7 +1772,7 @@ void SmParser::DoAttribut()
NextToken();
- pSNode->SetSubNodes(pAttr, nullptr);
+ pSNode->SetSubNodes(pAttr, nullptr); // the body will be filled later
pSNode->SetScaleMode(eScaleMode);
m_aNodeStack.push_front(std::move(pSNode));
}
diff --git a/starmath/source/visitors.cxx b/starmath/source/visitors.cxx
index cf3e92ec3241..7e11f083e69c 100644
--- a/starmath/source/visitors.cxx
+++ b/starmath/source/visitors.cxx
@@ -1531,9 +1531,10 @@ void SmCaretPosGraphBuildingVisitor::Visit( SmBraceNode* pNode )
*/
void SmCaretPosGraphBuildingVisitor::Visit( SmAttributNode* pNode )
{
- SmNode *pAttr = pNode->GetSubNode( 0 ),
- *pBody = pNode->GetSubNode( 1 );
- //None of the children can be NULL
+ SmNode *pAttr = pNode->Attribute(),
+ *pBody = pNode->Body();
+ assert(pAttr);
+ assert(pBody);
SmCaretPosGraphEntry *left = mpRightMost,
*attrLeft,
@@ -2085,7 +2086,7 @@ void SmNodeToTextVisitor::Visit( SmAlignNode* pNode )
void SmNodeToTextVisitor::Visit( SmAttributNode* pNode )
{
Append( pNode->GetToken( ).aText );
- LineToText( pNode->GetSubNode( 1 ) );
+ LineToText( pNode->Body() );
}
void SmNodeToTextVisitor::Visit( SmFontNode* pNode )