diff options
author | dante <dante19031999@gmail.com> | 2021-01-07 18:46:50 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2021-01-31 15:22:36 +0100 |
commit | ad57c26d4f16ac5b477a29106f4933ed1e1ca911 (patch) | |
tree | a859fbecf6d89ddfa9cbc333375c6dc4bec66827 /starmath/source/node.cxx | |
parent | 56d8010963d8f8f53e9a7e5baf26f2e1f2f2363a (diff) |
Increase node parser mathematical abstraction
The purpose is go to a simple parser in wich nodes are loaded by priorities.
For that purpose we shall first increase the parser abstraction and simplify to maximum node releted operations.
For that purpose:
- Can set as subnodes unique_ptr and pointers alike.
- Binary operators node->setsubnodes() will automatically adjust
data order in base to data type.
Change-Id: I050360cad34616709549e7461add0811dc26edc6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108944
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'starmath/source/node.cxx')
-rw-r--r-- | starmath/source/node.cxx | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/starmath/source/node.cxx b/starmath/source/node.cxx index f6fc8f0aed10..4de696dcabfa 100644 --- a/starmath/source/node.cxx +++ b/starmath/source/node.cxx @@ -387,6 +387,74 @@ void SmStructureNode::SetSubNodes(std::unique_ptr<SmNode> pFirst, std::unique_pt ClaimPaternity(); } +void SmStructureNode::SetSubNodes(SmNode* pFirst, SmNode* pSecond, SmNode* pThird) +{ + size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0)); + maSubNodes.resize( nSize ); + if (pFirst) + maSubNodes[0] = pFirst; + if (pSecond) + maSubNodes[1] = pSecond; + if (pThird) + maSubNodes[2] = pThird; + + ClaimPaternity(); +} + +void SmStructureNode::SetSubNodesBinMo(std::unique_ptr<SmNode> pFirst, std::unique_ptr<SmNode> pSecond, std::unique_ptr<SmNode> pThird) +{ + if(GetType()==SmNodeType::BinDiagonal) + { + size_t nSize = pSecond ? 3 : (pThird ? 2 : (pFirst ? 1 : 0)); + maSubNodes.resize( nSize ); + if (pFirst) + maSubNodes[0] = pFirst.release(); + if (pSecond) + maSubNodes[2] = pSecond.release(); + if (pThird) + maSubNodes[1] = pThird.release(); + } + else + { + size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0)); + maSubNodes.resize( nSize ); + if (pFirst) + maSubNodes[0] = pFirst.release(); + if (pSecond) + maSubNodes[1] = pSecond.release(); + if (pThird) + maSubNodes[2] = pThird.release(); + } + ClaimPaternity(); +} + +void SmStructureNode::SetSubNodesBinMo(SmNode* pFirst, SmNode* pSecond, SmNode* pThird) +{ + if(GetType()==SmNodeType::BinDiagonal) + { + size_t nSize = pSecond ? 3 : (pThird ? 2 : (pFirst ? 1 : 0)); + maSubNodes.resize( nSize ); + if (pFirst) + maSubNodes[0] = pFirst; + if (pSecond) + maSubNodes[1] = pSecond; + if (pThird) + maSubNodes[2] = pThird; + } + else + { + size_t nSize = pThird ? 3 : (pSecond ? 2 : (pFirst ? 1 : 0)); + maSubNodes.resize( nSize ); + if (pFirst) + maSubNodes[0] = pFirst; + if (pSecond) + maSubNodes[1] = pSecond; + if (pThird) + maSubNodes[2] = pThird; + } + ClaimPaternity(); +} + void SmStructureNode::SetSubNodes(SmNodeArray&& rNodeArray) { maSubNodes = std::move(rNodeArray); @@ -408,6 +476,18 @@ SmNode* SmStructureNode::GetSubNode(size_t nIndex) return maSubNodes[nIndex]; } +SmNode* SmStructureNode::GetSubNodeBinMo(size_t nIndex) const +{ + if(GetType()==SmNodeType::BinDiagonal) + { + if (nIndex==1) + nIndex = 2; + else if (nIndex==2) + nIndex = 1; + } + return maSubNodes[nIndex]; +} + void SmStructureNode::GetAccessibleText( OUStringBuffer &rText ) const { ForEachNonNull(const_cast<SmStructureNode *>(this), |