LCOV - code coverage report
Current view: top level - starmath/source - rtfexport.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 317 0.0 %
Date: 2014-04-14 Functions: 0 14 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  */
       9             : 
      10             : 
      11             : #include "rtfexport.hxx"
      12             : 
      13             : #include <rtl/ustring.hxx>
      14             : #include <svtools/rtfkeywd.hxx>
      15             : #include <filter/msfilter/rtfutil.hxx>
      16             : 
      17           0 : SmRtfExport::SmRtfExport(const SmNode* pIn)
      18             :     : SmWordExportBase(pIn)
      19             :     , m_pBuffer(0)
      20           0 :     , m_nEncoding(RTL_TEXTENCODING_DONTKNOW)
      21             : {
      22           0 : }
      23             : 
      24           0 : bool SmRtfExport::ConvertFromStarMath(OStringBuffer& rBuffer, rtl_TextEncoding nEncoding)
      25             : {
      26           0 :     if (!m_pTree)
      27           0 :         return false;
      28           0 :     m_pBuffer = &rBuffer;
      29           0 :     m_nEncoding = nEncoding;
      30           0 :     m_pBuffer->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE LO_STRING_SVTOOLS_RTF_MOMATH " ");
      31           0 :     HandleNode(m_pTree, 0);
      32           0 :     m_pBuffer->append("}"); // moMath
      33           0 :     return true;
      34             : }
      35             : 
      36             : // NOTE: This is still work in progress and unfinished, but it already covers a good
      37             : // part of the rtf math stuff.
      38             : 
      39           0 : void SmRtfExport::HandleVerticalStack(const SmNode* pNode, int nLevel)
      40             : {
      41           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MEQARR " ");
      42           0 :     int size = pNode->GetNumSubNodes();
      43           0 :     for (int i = 0; i < size; ++i)
      44             :     {
      45           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
      46           0 :         HandleNode(pNode->GetSubNode(i), nLevel + 1);
      47           0 :         m_pBuffer->append("}"); // me
      48             :     }
      49           0 :     m_pBuffer->append("}"); // meqArr
      50           0 : }
      51             : 
      52           0 : void SmRtfExport::HandleText(const SmNode* pNode, int /*nLevel*/)
      53             : {
      54           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
      55             : 
      56           0 :     if (pNode->GetToken().eType == TTEXT)  // literal text
      57           0 :         m_pBuffer->append(LO_STRING_SVTOOLS_RTF_MNOR " ");
      58             : 
      59           0 :     SmTextNode* pTemp=(SmTextNode*)pNode;
      60             :     SAL_INFO("starmath.rtf", "Text: " << pTemp->GetText());
      61           0 :     for (sal_Int32 i = 0; i < pTemp->GetText().getLength(); i++)
      62             :     {
      63           0 :         sal_uInt16 nChar = pTemp->GetText()[i];
      64           0 :         OUString aValue(SmTextNode::ConvertSymbolToUnicode(nChar));
      65           0 :         m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
      66           0 :     }
      67             : 
      68           0 :     m_pBuffer->append("}"); // mr
      69           0 : }
      70             : 
      71           0 : void SmRtfExport::HandleFractions(const SmNode* pNode, int nLevel, const char* type)
      72             : {
      73           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MF " ");
      74           0 :     if (type)
      75             :     {
      76           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFPR " ");
      77           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MTYPE " ");
      78           0 :         m_pBuffer->append(type);
      79           0 :         m_pBuffer->append("}"); // mtype
      80           0 :         m_pBuffer->append("}"); // mfPr
      81             :     }
      82             :     OSL_ASSERT(pNode->GetNumSubNodes() == 3);
      83           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNUM " ");
      84           0 :     HandleNode(pNode->GetSubNode(0), nLevel + 1);
      85           0 :     m_pBuffer->append("}"); // mnum
      86           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEN " ");
      87           0 :     HandleNode(pNode->GetSubNode(2), nLevel + 1);
      88           0 :     m_pBuffer->append("}"); // mden
      89           0 :     m_pBuffer->append("}"); // mf
      90           0 : }
      91             : 
      92           0 : void SmRtfExport::HandleAttribute(const SmAttributNode* pNode, int nLevel)
      93             : {
      94           0 :     switch (pNode->Attribute()->GetToken().eType)
      95             :     {
      96             :     case TCHECK:
      97             :     case TACUTE:
      98             :     case TGRAVE:
      99             :     case TBREVE:
     100             :     case TCIRCLE:
     101             :     case TVEC:
     102             :     case TTILDE:
     103             :     case THAT:
     104             :     case TDOT:
     105             :     case TDDOT:
     106             :     case TDDDOT:
     107             :     case TWIDETILDE:
     108             :     case TWIDEHAT:
     109             :     case TWIDEVEC:
     110             :     case TBAR:
     111             :     {
     112           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MACC " ");
     113           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MACCPR " ");
     114           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
     115           0 :         OUString aValue(pNode->Attribute()->GetToken().cMathChar);
     116           0 :         m_pBuffer->append(msfilter::rtfutil::OutString(aValue, m_nEncoding));
     117           0 :         m_pBuffer->append("}"); // mchr
     118           0 :         m_pBuffer->append("}"); // maccPr
     119           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     120           0 :         HandleNode(pNode->Body(), nLevel + 1);
     121           0 :         m_pBuffer->append("}"); // me
     122           0 :         m_pBuffer->append("}"); // macc
     123           0 :         break;
     124             :     }
     125             :     case TOVERLINE:
     126             :     case TUNDERLINE:
     127           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBAR " ");
     128           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBARPR " ");
     129           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ");
     130           0 :         m_pBuffer->append((pNode->Attribute()->GetToken().eType == TUNDERLINE) ? "bot" : "top");
     131           0 :         m_pBuffer->append("}"); // mpos
     132           0 :         m_pBuffer->append("}"); // mbarPr
     133           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     134           0 :         HandleNode(pNode->Body(), nLevel + 1);
     135           0 :         m_pBuffer->append("}"); // me
     136           0 :         m_pBuffer->append("}"); // mbar
     137           0 :         break;
     138             :     case TOVERSTRIKE:
     139           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBORDERBOX " ");
     140           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBORDERBOXPR " ");
     141           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDETOP " 1}");
     142           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDEBOT " 1}");
     143           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDELEFT " 1}");
     144           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MHIDERIGHT " 1}");
     145           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSTRIKEH " 1}");
     146           0 :         m_pBuffer->append("}"); // mborderBoxPr
     147           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     148           0 :         HandleNode(pNode->Body(), nLevel + 1);
     149           0 :         m_pBuffer->append("}"); // me
     150           0 :         m_pBuffer->append("}"); // mborderBox
     151           0 :         break;
     152             :     default:
     153           0 :         HandleAllSubNodes(pNode, nLevel);
     154           0 :         break;
     155             :     }
     156           0 : }
     157             : 
     158           0 : void SmRtfExport::HandleRoot(const SmRootNode* pNode, int nLevel)
     159             : {
     160           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MRAD " ");
     161           0 :     if (const SmNode* argument = pNode->Argument())
     162             :     {
     163           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEG " ");
     164           0 :         HandleNode(argument, nLevel + 1);
     165           0 :         m_pBuffer->append("}"); // mdeg
     166             :     }
     167             :     else
     168             :     {
     169           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MRADPR " ");
     170           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEGHIDE " 1}");
     171           0 :         m_pBuffer->append("}"); // mradPr
     172           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDEG " }"); // empty but present
     173             :     }
     174           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     175           0 :     HandleNode(pNode->Body(), nLevel + 1);
     176           0 :     m_pBuffer->append("}"); // me
     177           0 :     m_pBuffer->append("}"); // mrad
     178           0 : }
     179             : 
     180             : namespace
     181             : {
     182           0 : OString mathSymbolToString(const SmNode* node, rtl_TextEncoding nEncoding)
     183             : {
     184             :     assert(node->GetType() == NMATH || node->GetType() == NMATHIDENT);
     185           0 :     const SmTextNode* txtnode = static_cast<const SmTextNode*>(node);
     186           0 :     if (txtnode->GetText().isEmpty())
     187           0 :         return OString();
     188             :     assert(txtnode->GetText().getLength() == 1);
     189           0 :     sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode(txtnode->GetText()[0]);
     190           0 :     OUString aValue(chr);
     191           0 :     return msfilter::rtfutil::OutString(aValue, nEncoding);
     192             : }
     193             : }
     194             : 
     195           0 : void SmRtfExport::HandleOperator(const SmOperNode* pNode, int nLevel)
     196             : {
     197             :     SAL_INFO("starmath.rtf", "Operator: " << int(pNode->GetToken().eType));
     198           0 :     switch (pNode->GetToken().eType)
     199             :     {
     200             :     case TINT:
     201             :     case TINTD:
     202             :     case TIINT:
     203             :     case TIIINT:
     204             :     case TLINT:
     205             :     case TLLINT:
     206             :     case TLLLINT:
     207             :     case TPROD:
     208             :     case TCOPROD:
     209             :     case TSUM:
     210             :     {
     211           0 :         const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0;
     212           0 :         const SmNode* operation = subsup ? subsup->GetBody() : pNode->GetSubNode(0);
     213           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARY " ");
     214           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARYPR " ");
     215           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
     216           0 :         m_pBuffer->append(mathSymbolToString(operation, m_nEncoding));
     217           0 :         m_pBuffer->append("}"); // mchr
     218           0 :         if (!subsup || !subsup->GetSubSup(CSUB))
     219           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUBHIDE " 1}");
     220           0 :         if (!subsup || !subsup->GetSubSup(CSUP))
     221           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUPHIDE " 1}");
     222           0 :         m_pBuffer->append("}"); // mnaryPr
     223           0 :         if (!subsup || !subsup->GetSubSup(CSUB))
     224           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " }");
     225             :         else
     226             :         {
     227           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     228           0 :             HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
     229           0 :             m_pBuffer->append("}"); // msub
     230             :         }
     231           0 :         if (!subsup || !subsup->GetSubSup(CSUP))
     232           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " }");
     233             :         else
     234             :         {
     235           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     236           0 :             HandleNode(subsup->GetSubSup(CSUP), nLevel + 1);
     237           0 :             m_pBuffer->append("}"); // msup
     238             :         }
     239           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     240           0 :         HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
     241           0 :         m_pBuffer->append("}"); // me
     242           0 :         m_pBuffer->append("}"); // mnary
     243           0 :         break;
     244             :     }
     245             :     case TLIM:
     246           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFUNC " ");
     247           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFNAME " ");
     248           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     249           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     250           0 :         HandleNode(pNode->GetSymbol(), nLevel + 1);
     251           0 :         m_pBuffer->append("}"); // me
     252           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     253           0 :         if (const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0)
     254           0 :             if (subsup->GetSubSup(CSUB))
     255           0 :                 HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
     256           0 :         m_pBuffer->append("}"); // mlim
     257           0 :         m_pBuffer->append("}"); // mlimLow
     258           0 :         m_pBuffer->append("}"); // mfName
     259           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     260           0 :         HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
     261           0 :         m_pBuffer->append("}"); // me
     262           0 :         m_pBuffer->append("}"); // mfunc
     263           0 :         break;
     264             :     default:
     265             :         SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled oper type");
     266           0 :         break;
     267             :     }
     268           0 : }
     269             : 
     270           0 : void SmRtfExport::HandleSubSupScriptInternal(const SmSubSupNode* pNode, int nLevel, int flags)
     271             : {
     272             : // rtf supports only a certain combination of sub/super scripts, but LO can have any,
     273             : // so try to merge it using several tags if necessary
     274           0 :     if (flags == 0) // none
     275           0 :         return;
     276           0 :     if ((flags & (1 << RSUP | 1 << RSUB)) == (1 << RSUP | 1 << RSUB))
     277             :     {
     278             :         // m:sSubSup
     279           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUBSUP " ");
     280           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     281           0 :         flags &= ~(1 << RSUP | 1 << RSUB);
     282           0 :         if (flags == 0)
     283           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     284             :         else
     285           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     286           0 :         m_pBuffer->append("}"); // me
     287           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     288           0 :         HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
     289           0 :         m_pBuffer->append("}"); // msub
     290           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     291           0 :         HandleNode(pNode->GetSubSup(RSUP), nLevel + 1);
     292           0 :         m_pBuffer->append("}"); // msup
     293           0 :         m_pBuffer->append("}"); // msubSup
     294             :     }
     295           0 :     else if ((flags & (1 << RSUB)) == 1 << RSUB)
     296             :     {
     297             :         // m:sSub
     298           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUB " ");
     299           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     300           0 :         flags &= ~(1 << RSUB);
     301           0 :         if (flags == 0)
     302           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     303             :         else
     304           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     305           0 :         m_pBuffer->append("}"); // me
     306           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     307           0 :         HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
     308           0 :         m_pBuffer->append("}"); // msub
     309           0 :         m_pBuffer->append("}"); // msSub
     310             :     }
     311           0 :     else if ((flags & (1 << RSUP)) == 1 << RSUP)
     312             :     {
     313             :         // m:sSup
     314           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUP " ");
     315           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     316           0 :         flags &= ~(1 << RSUP);
     317           0 :         if (flags == 0)
     318           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     319             :         else
     320           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     321           0 :         m_pBuffer->append("}"); // me
     322           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     323           0 :         HandleNode(pNode->GetSubSup(RSUP), nLevel + 1);
     324           0 :         m_pBuffer->append("}"); // msup
     325           0 :         m_pBuffer->append("}"); // msSup
     326             :     }
     327           0 :     else if ((flags & (1 << LSUP | 1 << LSUB)) == (1 << LSUP | 1 << LSUB))
     328             :     {
     329             :         // m:sPre
     330           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSPRE " ");
     331           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     332           0 :         HandleNode(pNode->GetSubSup(LSUB), nLevel + 1);
     333           0 :         m_pBuffer->append("}"); // msub
     334           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     335           0 :         HandleNode(pNode->GetSubSup(LSUP), nLevel + 1);
     336           0 :         m_pBuffer->append("}"); // msup
     337           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     338           0 :         flags &= ~(1 << LSUP | 1 << LSUB);
     339           0 :         if (flags == 0)
     340           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     341             :         else
     342           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     343           0 :         m_pBuffer->append("}"); // me
     344           0 :         m_pBuffer->append("}"); // msPre
     345             :     }
     346           0 :     else if ((flags & (1 << CSUB)) == (1 << CSUB))
     347             :     {
     348             :         // m:limLow looks like a good element for central superscript
     349           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     350           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     351           0 :         flags &= ~(1 << CSUB);
     352           0 :         if (flags == 0)
     353           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     354             :         else
     355           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     356           0 :         m_pBuffer->append("}"); // me
     357           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     358           0 :         HandleNode(pNode->GetSubSup(CSUB), nLevel + 1);
     359           0 :         m_pBuffer->append("}"); // mlim
     360           0 :         m_pBuffer->append("}"); // mlimLow
     361             :     }
     362           0 :     else if ((flags & (1 << CSUP)) == (1 << CSUP))
     363             :     {
     364             :         // m:limUpp looks like a good element for central superscript
     365           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
     366           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     367           0 :         flags &= ~(1 << CSUP);
     368           0 :         if (flags == 0)
     369           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     370             :         else
     371           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     372           0 :         m_pBuffer->append("}"); // me
     373           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     374           0 :         HandleNode(pNode->GetSubSup(CSUP), nLevel + 1);
     375           0 :         m_pBuffer->append("}"); // mlim
     376           0 :         m_pBuffer->append("}"); // mlimUpp
     377             :     }
     378             :     else
     379             :         SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled subsup type");
     380             : }
     381             : 
     382           0 : void SmRtfExport::HandleMatrix(const SmMatrixNode* pNode, int nLevel)
     383             : {
     384           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MM " ");
     385           0 :     for (int row = 0; row < pNode->GetNumRows(); ++row)
     386             :     {
     387           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MMR " ");
     388           0 :         for (int col = 0; col < pNode->GetNumCols(); ++col)
     389             :         {
     390           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     391           0 :             if (const SmNode* node = pNode->GetSubNode(row * pNode->GetNumCols() + col))
     392           0 :                 HandleNode(node, nLevel + 1);
     393           0 :             m_pBuffer->append("}"); // me
     394             :         }
     395           0 :         m_pBuffer->append("}"); // mmr
     396             :     }
     397           0 :     m_pBuffer->append("}"); // mm
     398           0 : }
     399             : 
     400           0 : void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
     401             : {
     402           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MD " ");
     403           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDPR " ");
     404           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBEGCHR " ");
     405           0 :     m_pBuffer->append(mathSymbolToString(pNode->OpeningBrace(), m_nEncoding));
     406           0 :     m_pBuffer->append("}"); // mbegChr
     407           0 :     std::vector< const SmNode* > subnodes;
     408           0 :     if (pNode->Body()->GetType() == NBRACEBODY)
     409             :     {
     410           0 :         const SmBracebodyNode* body = static_cast<const SmBracebodyNode*>(pNode->Body());
     411           0 :         bool separatorWritten = false; // assume all separators are the same
     412           0 :         for (int i = 0; i < body->GetNumSubNodes(); ++i)
     413             :         {
     414           0 :             const SmNode* subnode = body->GetSubNode(i);
     415           0 :             if (subnode->GetType() == NMATH || subnode->GetType() == NMATHIDENT)
     416             :             {
     417             :                 // do not write, but write what separator it is
     418           0 :                 const SmMathSymbolNode* math = static_cast<const SmMathSymbolNode*>(subnode);
     419           0 :                 if (!separatorWritten)
     420             :                 {
     421           0 :                     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSEPCHR " ");
     422           0 :                     m_pBuffer->append(mathSymbolToString(math, m_nEncoding));
     423           0 :                     m_pBuffer->append("}"); // msepChr
     424           0 :                     separatorWritten = true;
     425             :                 }
     426             :             }
     427             :             else
     428           0 :                 subnodes.push_back(subnode);
     429             :         }
     430             :     }
     431             :     else
     432           0 :         subnodes.push_back(pNode->Body());
     433           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MENDCHR " ");
     434           0 :     m_pBuffer->append(mathSymbolToString(pNode->ClosingBrace(), m_nEncoding));
     435           0 :     m_pBuffer->append("}"); // mendChr
     436           0 :     m_pBuffer->append("}"); // mdPr
     437           0 :     for (unsigned int i = 0; i < subnodes.size(); ++i)
     438             :     {
     439           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     440           0 :         HandleNode(subnodes[ i ], nLevel + 1);
     441           0 :         m_pBuffer->append("}"); // me
     442             :     }
     443           0 :     m_pBuffer->append("}"); // md
     444           0 : }
     445             : 
     446           0 : void SmRtfExport::HandleVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel)
     447             : {
     448             :     SAL_INFO("starmath.rtf", "Vertical: " << int(pNode->GetToken().eType));
     449           0 :     switch (pNode->GetToken().eType)
     450             :     {
     451             :     case TOVERBRACE:
     452             :     case TUNDERBRACE:
     453             :     {
     454           0 :         bool top = (pNode->GetToken().eType == TOVERBRACE);
     455           0 :         if (top)
     456           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
     457             :         else
     458           0 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     459           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     460           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHR " ");
     461           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHRPR " ");
     462           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
     463           0 :         m_pBuffer->append(mathSymbolToString(pNode->Brace(), m_nEncoding));
     464           0 :         m_pBuffer->append("}"); // mchr
     465             :         // TODO not sure if pos and vertJc are correct
     466           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ").append(top ? "top" : "bot").append("}");
     467           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MVERTJC " ").append(top ? "bot" : "top").append("}");
     468           0 :         m_pBuffer->append("}"); // mgroupChrPr
     469           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     470           0 :         HandleNode(pNode->Body(), nLevel + 1);
     471           0 :         m_pBuffer->append("}"); // me
     472           0 :         m_pBuffer->append("}"); // mgroupChr
     473           0 :         m_pBuffer->append("}"); // me
     474           0 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     475           0 :         HandleNode(pNode->Script(), nLevel + 1);
     476           0 :         m_pBuffer->append("}"); // mlim
     477           0 :         m_pBuffer->append("}"); // mlimUpp or mlimLow
     478           0 :         break;
     479             :     }
     480             :     default:
     481             :         SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled vertical brace type");
     482           0 :         break;
     483             :     }
     484           0 : }
     485             : 
     486           0 : void SmRtfExport::HandleBlank()
     487             : {
     488           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
     489           0 :     m_pBuffer->append(" ");
     490           0 :     m_pBuffer->append("}"); // mr
     491           0 : }
     492             : 
     493             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10