starmath/inc/node.hxx            |    6 +++---
 starmath/source/mathmlimport.cxx |   21 ++++++++-------------
 starmath/source/node.cxx         |   14 ++++++--------
 starmath/source/parse.cxx        |    2 +-
 starmath/source/visitors.cxx     |    9 +++++----
 5 files changed, 23 insertions(+), 29 deletions(-)

New commits:
commit dd612a61f9df81343ed5f810068002a7a25046a7
Author: Takeshi Abe <t...@fixedpoint.jp>
Date:   Fri Aug 5 23:32:49 2016 +0900

    starmath: complete SmAttributNode has just 2 subnodes
    
    Change-Id: Ifbecef188b314d599d7e97717934143b2aac8c09
    Reviewed-on: https://gerrit.libreoffice.org/27912
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Takeshi Abe <t...@fixedpoint.jp>

diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index e0b2019..a579221 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 03accbf..8946c6f 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 5b45745..d5e4a45 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 9ac2d93..1e11be3 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 cf3e92e..7e11f08 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 )
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to