diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2012-07-25 17:00:45 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2012-07-25 17:07:37 +0200 |
commit | 1ec55802d90334d2b6112cfc0df43c4cedcd3d1b (patch) | |
tree | 79b54bf3cde6acc0fbb2433b7eb42e9ff2fab26c /starmath | |
parent | 69df3928f374f4c331b5208a7cdb282f05cba87d (diff) |
export RTF_MLIM and related keywords
Change-Id: I533807168fea34216bfd2a7cf64d13bca4815d25
Diffstat (limited to 'starmath')
-rw-r--r-- | starmath/source/rtfexport.cxx | 78 |
1 files changed, 75 insertions, 3 deletions
diff --git a/starmath/source/rtfexport.cxx b/starmath/source/rtfexport.cxx index dbce7ed43148..493a483657b1 100644 --- a/starmath/source/rtfexport.cxx +++ b/starmath/source/rtfexport.cxx @@ -41,7 +41,7 @@ SmRtfExport::SmRtfExport(const SmNode* pIn) bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer) { - if (m_pTree == NULL) + if (!m_pTree) return false; m_pBuffer = &rBuffer; m_pBuffer->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE "\\moMath"); @@ -68,6 +68,9 @@ void SmRtfExport::HandleNode(const SmNode* pNode, int nLevel) case NBRACE: HandleBrace( static_cast< const SmBraceNode* >( pNode ), nLevel ); break; + case NOPER: + HandleOperator(static_cast<const SmOperNode*>(pNode), nLevel); + break; case NBINHOR: HandleBinaryOperation(static_cast<const SmBinHorNode*>(pNode), nLevel); break; @@ -275,9 +278,78 @@ OString mathSymbolToString(const SmNode* node) } } -void SmRtfExport::HandleOperator(const SmOperNode* /*pNode*/, int /*nLevel*/) +void SmRtfExport::HandleOperator(const SmOperNode* pNode, int nLevel) { - SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC); + SAL_INFO("starmath.rtf", "Operator: " << int(pNode->GetToken().eType)); + switch (pNode->GetToken().eType) + { + case TINT: + case TIINT: + case TIIINT: + case TLINT: + case TLLINT: + case TLLLINT: + case TPROD: + case TCOPROD: + case TSUM: + { + const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0; + const SmNode* operation = subsup ? subsup->GetBody() : pNode->GetSubNode(0); + m_pBuffer->append("{\\mnary "); + m_pBuffer->append("{\\mnaryPr "); + m_pBuffer->append("{\\mchr "); + m_pBuffer->append(mathSymbolToString(operation)); + m_pBuffer->append("}"); // mchr + if (!subsup || !subsup->GetSubSup(CSUB)) + m_pBuffer->append("{\\msubHide 1}"); + if (!subsup || !subsup->GetSubSup(CSUP)) + m_pBuffer->append("{\\msupHide 1}"); + m_pBuffer->append("}"); // mnaryPr + if (!subsup || !subsup->GetSubSup(CSUB)) + m_pBuffer->append("{\\msub }"); + else + { + m_pBuffer->append("{\\msub "); + HandleNode(subsup->GetSubSup(CSUB), nLevel + 1); + m_pBuffer->append("}"); // msub + } + if (!subsup || !subsup->GetSubSup( CSUP )) + m_pBuffer->append("{\\msup }"); + else + { + m_pBuffer->append("{\\msup "); + HandleNode(subsup->GetSubSup(CSUP), nLevel + 1); + m_pBuffer->append("}"); // msup + } + m_pBuffer->append("{\\me "); + HandleNode(pNode->GetSubNode(1), nLevel + 1); // body + m_pBuffer->append("}"); // me + m_pBuffer->append("}"); // mnary + break; + } + case TLIM: + m_pBuffer->append("{\\mfunc "); + m_pBuffer->append("{\\mfName "); + m_pBuffer->append("{\\mlimLow "); + m_pBuffer->append("{\\me "); + HandleNode(pNode->GetSymbol(), nLevel + 1); + m_pBuffer->append("}"); // me + m_pBuffer->append("{\\mlim "); + if (const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>( pNode->GetSubNode(0)) : 0) + if (subsup->GetSubSup(CSUB)) + HandleNode(subsup->GetSubSup(CSUB), nLevel + 1); + m_pBuffer->append("}"); // mlim + m_pBuffer->append("}"); // mlimLow + m_pBuffer->append("}"); // mfName + m_pBuffer->append("{\\me "); + HandleNode(pNode->GetSubNode(1), nLevel + 1); // body + m_pBuffer->append("}"); // me + m_pBuffer->append("}"); // mfunc + break; + default: + SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled oper type"); + break; + } } void SmRtfExport::HandleSubSupScript(const SmSubSupNode* /*pNode*/, int /*nLevel*/) |