[Libreoffice-commits] core.git: starmath/inc starmath/source

Takeshi Abe tabe at fixedpoint.jp
Wed Jun 8 06:27:11 UTC 2016


 starmath/inc/document.hxx        |    6 +++---
 starmath/inc/node.hxx            |    4 +---
 starmath/inc/parse.hxx           |    4 ++--
 starmath/source/mathmlimport.cxx |    6 +++---
 starmath/source/node.cxx         |    6 ------
 starmath/source/parse.cxx        |   13 +++++--------
 6 files changed, 14 insertions(+), 25 deletions(-)

New commits:
commit 261f734b3c0e62ada51485ba81a535d32049c946
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date:   Tue Jun 7 17:28:40 2016 +0900

    starmath: The formula tree must be of type SmTableNode
    
    This also omits the last push & pop on m_aNodeStack at the end
    of parsing.
    
    Change-Id: Iefff8fa801ea7cb9015d6cba0d5a972dee675cb7
    Reviewed-on: https://gerrit.libreoffice.org/26003
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Takeshi Abe <tabe at fixedpoint.jp>

diff --git a/starmath/inc/document.hxx b/starmath/inc/document.hxx
index 1b51926..667102d 100644
--- a/starmath/inc/document.hxx
+++ b/starmath/inc/document.hxx
@@ -91,7 +91,7 @@ class SM_DLLPUBLIC SmDocShell : public SfxObjectShell, public SfxListener
     SmFormat            maFormat;
     SmParser            maParser;
     OUString            maAccText;
-    SmNode             *mpTree;
+    SmTableNode        *mpTree;
     SfxItemPool        *mpEditEngineItemPool;
     EditEngine         *mpEditEngine;
     VclPtr<SfxPrinter>  mpPrinter;       //q.v. comment to SmPrinter Access!
@@ -177,8 +177,8 @@ public:
 
     void            Parse();
     SmParser &      GetParser() { return maParser; }
-    const SmNode *  GetFormulaTree() const  { return mpTree; }
-    void            SetFormulaTree(SmNode *&rTree) { mpTree = rTree; }
+    const SmTableNode *GetFormulaTree() const  { return mpTree; }
+    void            SetFormulaTree(SmTableNode *pTree) { mpTree = pTree; }
 
     const std::set< OUString > &    GetUsedSymbols() const  { return maUsedSymbols; }
 
diff --git a/starmath/inc/node.hxx b/starmath/inc/node.hxx
index 9e09269..af03a7b 100644
--- a/starmath/inc/node.hxx
+++ b/starmath/inc/node.hxx
@@ -189,8 +189,6 @@ public:
     const SmNode *  FindTokenAt(sal_uInt16 nRow, sal_uInt16 nCol) const;
     const SmNode *  FindRectClosestTo(const Point &rPoint) const;
 
-    virtual long    GetFormulaBaseline() const;
-
     /** Accept a visitor
      * Calls the method for this class on the visitor
      */
@@ -678,7 +676,7 @@ public:
     virtual const SmNode * GetLeftMost() const override;
 
     virtual void Arrange(OutputDevice &rDev, const SmFormat &rFormat) override;
-    virtual long GetFormulaBaseline() const override;
+    long GetFormulaBaseline() const;
 
     void Accept(SmVisitor* pVisitor) override;
 };
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index 3ebeb2c..2c8e9b2 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -59,7 +59,7 @@ class SmParser
     inline bool     TokenInGroup( TG nGroup );
 
     // grammar
-    void    DoTable();
+    SmTableNode *DoTable();
     void    DoLine();
     void    DoExpression();
     void    DoRelation();
@@ -99,7 +99,7 @@ public:
                  SmParser();
 
     /** Parse rBuffer to formula tree */
-    SmNode      *Parse(const OUString &rBuffer);
+    SmTableNode *Parse(const OUString &rBuffer);
     /** Parse rBuffer to formula subtree that constitutes an expression */
     SmNode      *ParseExpression(const OUString &rBuffer);
 
diff --git a/starmath/source/mathmlimport.cxx b/starmath/source/mathmlimport.cxx
index 5be0526..03accbf 100644
--- a/starmath/source/mathmlimport.cxx
+++ b/starmath/source/mathmlimport.cxx
@@ -484,8 +484,8 @@ void SmXMLImport::endDocument()
     throw(xml::sax::SAXException, uno::RuntimeException, std::exception)
 {
     //Set the resulted tree into the SmDocShell where it belongs
-    SmNode *pTree;
-    if (nullptr != (pTree = GetTree()))
+    SmNode *pTree = GetTree();
+    if (pTree && pTree->GetType() == NTABLE)
     {
         uno::Reference <frame::XModel> xModel = GetModel();
         uno::Reference <lang::XUnoTunnel> xTunnel(xModel,uno::UNO_QUERY);
@@ -496,7 +496,7 @@ void SmXMLImport::endDocument()
         {
             SmDocShell *pDocShell =
                 static_cast<SmDocShell*>(pModel->GetObjectShell());
-            pDocShell->SetFormulaTree(pTree);
+            pDocShell->SetFormulaTree(static_cast<SmTableNode *>(pTree));
             if (aText.isEmpty())  //If we picked up no annotation text
             {
                 // Get text from imported formula
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx
index 71c48ba..8f7f52c 100644
--- a/starmath/source/node.cxx
+++ b/starmath/source/node.cxx
@@ -393,12 +393,6 @@ const SmNode * SmNode::FindNodeWithAccessibleIndex(sal_Int32 nAccIdx) const
     return pResult;
 }
 
-long SmNode::GetFormulaBaseline() const
-{
-    SAL_WARN("starmath", "This dummy implementation should not have been called.");
-    return 0;
-}
-
 
 SmStructureNode::~SmStructureNode()
 {
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 591404a..5674e3d 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -944,7 +944,7 @@ void SmParser::NextToken()
 
 // grammar
 
-void SmParser::DoTable()
+SmTableNode *SmParser::DoTable()
 {
     DoLine();
     while (m_aCurToken.eType == TNEWLINE)
@@ -962,9 +962,9 @@ void SmParser::DoTable()
         *rIt = popOrZero(m_aNodeStack);
     }
 
-    std::unique_ptr<SmStructureNode> pSNode(new SmTableNode(m_aCurToken));
+    std::unique_ptr<SmTableNode> pSNode(new SmTableNode(m_aCurToken));
     pSNode->SetSubNodes(LineArray);
-    m_aNodeStack.push_front(std::move(pSNode));
+    return pSNode.release();
 }
 
 void SmParser::DoAlign()
@@ -2326,7 +2326,7 @@ SmParser::SmParser()
 {
 }
 
-SmNode *SmParser::Parse(const OUString &rBuffer)
+SmTableNode *SmParser::Parse(const OUString &rBuffer)
 {
     ClearUsedSymbols();
 
@@ -2342,10 +2342,7 @@ SmNode *SmParser::Parse(const OUString &rBuffer)
     m_aNodeStack.clear();
 
     NextToken();
-    DoTable();
-
-    SmNode* result = popOrZero(m_aNodeStack);
-    return result;
+    return DoTable();
 }
 
 SmNode *SmParser::ParseExpression(const OUString &rBuffer)


More information about the Libreoffice-commits mailing list