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

Generated by: LCOV version 1.11