LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/starmath/source - rtfexport.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 301 317 95.0 %
Date: 2013-07-09 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 <rtl/ustring.hxx>
      14             : #include <svtools/rtfkeywd.hxx>
      15             : #include <filter/msfilter/rtfutil.hxx>
      16             : 
      17          30 : SmRtfExport::SmRtfExport(const SmNode* pIn)
      18             :     : SmWordExportBase(pIn)
      19          30 :       , m_pBuffer(0)
      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 :     SmTextNode* pTemp=(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          58 : OString mathSymbolToString(const SmNode* node, rtl_TextEncoding nEncoding)
     181             : {
     182             :     assert(node->GetType() == NMATH || node->GetType() == NMATHIDENT);
     183          58 :     const SmTextNode* txtnode = static_cast<const SmTextNode*>(node);
     184          58 :     if (txtnode->GetText().isEmpty())
     185           1 :         return OString();
     186             :     assert(txtnode->GetText().getLength() == 1);
     187          57 :     sal_Unicode chr = SmTextNode::ConvertSymbolToUnicode(txtnode->GetText()[0]);
     188          57 :     OUString aValue(chr);
     189          57 :     return msfilter::rtfutil::OutString(aValue, nEncoding);
     190             : }
     191             : }
     192             : 
     193           9 : void SmRtfExport::HandleOperator(const SmOperNode* pNode, int nLevel)
     194             : {
     195             :     SAL_INFO("starmath.rtf", "Operator: " << int(pNode->GetToken().eType));
     196           9 :     switch (pNode->GetToken().eType)
     197             :     {
     198             :         case TINT:
     199             :         case TIINT:
     200             :         case TIIINT:
     201             :         case TLINT:
     202             :         case TLLINT:
     203             :         case TLLLINT:
     204             :         case TPROD:
     205             :         case TCOPROD:
     206             :         case TSUM:
     207             :         {
     208           8 :             const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>(pNode->GetSubNode(0)) : 0;
     209           8 :             const SmNode* operation = subsup ? subsup->GetBody() : pNode->GetSubNode(0);
     210           8 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARY " ");
     211           8 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MNARYPR " ");
     212           8 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
     213           8 :             m_pBuffer->append(mathSymbolToString(operation, m_nEncoding));
     214           8 :             m_pBuffer->append("}"); // mchr
     215           8 :             if (!subsup || !subsup->GetSubSup(CSUB))
     216           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUBHIDE " 1}");
     217           8 :             if (!subsup || !subsup->GetSubSup(CSUP))
     218           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUPHIDE " 1}");
     219           8 :             m_pBuffer->append("}"); // mnaryPr
     220           8 :             if (!subsup || !subsup->GetSubSup(CSUB))
     221           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " }");
     222             :             else
     223             :             {
     224           7 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     225           7 :                 HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
     226           7 :                 m_pBuffer->append("}"); // msub
     227             :             }
     228           8 :             if (!subsup || !subsup->GetSubSup( CSUP ))
     229           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " }");
     230             :             else
     231             :             {
     232           7 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     233           7 :                 HandleNode(subsup->GetSubSup(CSUP), nLevel + 1);
     234           7 :                 m_pBuffer->append("}"); // msup
     235             :             }
     236           8 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     237           8 :             HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
     238           8 :             m_pBuffer->append("}"); // me
     239           8 :             m_pBuffer->append("}"); // mnary
     240           8 :             break;
     241             :         }
     242             :         case TLIM:
     243           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFUNC " ");
     244           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MFNAME " ");
     245           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     246           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     247           1 :             HandleNode(pNode->GetSymbol(), nLevel + 1);
     248           1 :             m_pBuffer->append("}"); // me
     249           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     250           1 :             if (const SmSubSupNode* subsup = pNode->GetSubNode(0)->GetType() == NSUBSUP ? static_cast<const SmSubSupNode*>( pNode->GetSubNode(0)) : 0)
     251           1 :                 if (subsup->GetSubSup(CSUB))
     252           1 :                     HandleNode(subsup->GetSubSup(CSUB), nLevel + 1);
     253           1 :             m_pBuffer->append("}"); // mlim
     254           1 :             m_pBuffer->append("}"); // mlimLow
     255           1 :             m_pBuffer->append("}"); // mfName
     256           1 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     257           1 :             HandleNode(pNode->GetSubNode(1), nLevel + 1); // body
     258           1 :             m_pBuffer->append("}"); // me
     259           1 :             m_pBuffer->append("}"); // mfunc
     260           1 :             break;
     261             :         default:
     262             :             SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled oper type");
     263           0 :             break;
     264             :     }
     265           9 : }
     266             : 
     267          27 : void SmRtfExport::HandleSubSupScriptInternal(const SmSubSupNode* pNode, int nLevel, int flags)
     268             : {
     269             : // rtf supports only a certain combination of sub/super scripts, but LO can have any,
     270             : // so try to merge it using several tags if necessary
     271          27 :     if (flags == 0) // none
     272          27 :         return;
     273          27 :     if ((flags & (1 << RSUP | 1 << RSUB)) == (1 << RSUP | 1 << RSUB))
     274             :     { // m:sSubSup
     275           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUBSUP " ");
     276           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     277           2 :         flags &= ~(1 << RSUP | 1 << RSUB);
     278           2 :         if (flags == 0)
     279           2 :             HandleNode(pNode->GetBody(), nLevel + 1);
     280             :         else
     281           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     282           2 :         m_pBuffer->append("}"); // me
     283           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     284           2 :         HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
     285           2 :         m_pBuffer->append("}"); // msub
     286           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     287           2 :         HandleNode(pNode->GetSubSup(RSUP ), nLevel + 1);
     288           2 :         m_pBuffer->append("}"); // msup
     289           2 :         m_pBuffer->append("}"); // msubSup
     290             :     }
     291          25 :     else if ((flags & (1 << RSUB)) == 1 << RSUB)
     292             :     { // m:sSub
     293           4 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUB " ");
     294           4 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     295           4 :         flags &= ~(1 << RSUB);
     296           4 :         if (flags == 0)
     297           4 :             HandleNode(pNode->GetBody(), nLevel + 1);
     298             :         else
     299           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     300           4 :         m_pBuffer->append("}"); // me
     301           4 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     302           4 :         HandleNode(pNode->GetSubSup(RSUB), nLevel + 1);
     303           4 :         m_pBuffer->append("}"); // msub
     304           4 :         m_pBuffer->append("}"); // msSub
     305             :     }
     306          21 :     else if ((flags & (1 << RSUP)) == 1 << RSUP)
     307             :     { // m:sSup
     308          17 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSSUP " ");
     309          17 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     310          17 :         flags &= ~(1 << RSUP);
     311          17 :         if (flags == 0)
     312          17 :             HandleNode(pNode->GetBody(), nLevel + 1);
     313             :         else
     314           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     315          17 :         m_pBuffer->append("}"); // me
     316          17 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     317          17 :         HandleNode(pNode->GetSubSup(RSUP), nLevel + 1);
     318          17 :         m_pBuffer->append("}"); // msup
     319          17 :         m_pBuffer->append("}"); // msSup
     320             :     }
     321           4 :     else if ((flags & (1 << LSUP | 1 << LSUB)) == (1 << LSUP | 1 << LSUB))
     322             :     { // m:sPre
     323           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSPRE " ");
     324           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUB " ");
     325           2 :         HandleNode(pNode->GetSubSup(LSUB ), nLevel + 1);
     326           2 :         m_pBuffer->append("}"); // msub
     327           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSUP " ");
     328           2 :         HandleNode(pNode->GetSubSup(LSUP), nLevel + 1);
     329           2 :         m_pBuffer->append("}"); // msup
     330           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     331           2 :         flags &= ~(1 << LSUP | 1 << LSUB);
     332           2 :         if (flags == 0)
     333           2 :             HandleNode(pNode->GetBody(), nLevel + 1);
     334             :         else
     335           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     336           2 :         m_pBuffer->append("}"); // me
     337           2 :         m_pBuffer->append("}"); // msPre
     338             :     }
     339           2 :     else if ((flags & (1 << CSUB)) == (1 << CSUB))
     340             :     { // m:limLow looks like a good element for central superscript
     341           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     342           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     343           1 :         flags &= ~(1 << CSUB);
     344           1 :         if (flags == 0)
     345           0 :             HandleNode(pNode->GetBody(), nLevel + 1);
     346             :         else
     347           1 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     348           1 :         m_pBuffer->append("}"); // me
     349           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     350           1 :         HandleNode(pNode->GetSubSup(CSUB), nLevel + 1);
     351           1 :         m_pBuffer->append("}"); // mlim
     352           1 :         m_pBuffer->append("}"); // mlimLow
     353             :     }
     354           1 :     else if ((flags & (1 << CSUP)) == (1 << CSUP))
     355             :     { // m:limUpp looks like a good element for central superscript
     356           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
     357           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     358           1 :         flags &= ~(1 << CSUP);
     359           1 :         if (flags == 0)
     360           1 :             HandleNode(pNode->GetBody(), nLevel + 1);
     361             :         else
     362           0 :             HandleSubSupScriptInternal(pNode, nLevel, flags);
     363           1 :         m_pBuffer->append("}"); // me
     364           1 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     365           1 :         HandleNode(pNode->GetSubSup(CSUP), nLevel + 1);
     366           1 :         m_pBuffer->append("}"); // mlim
     367           1 :         m_pBuffer->append("}"); // mlimUpp
     368             :     }
     369             :     else
     370             :         SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled subsup type");
     371             : }
     372             : 
     373           1 : void SmRtfExport::HandleMatrix(const SmMatrixNode* pNode, int nLevel)
     374             : {
     375           1 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MM " ");
     376           3 :     for (int row = 0; row < pNode->GetNumRows(); ++row )
     377             :     {
     378           2 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MMR " ");
     379           6 :         for (int col = 0; col < pNode->GetNumCols(); ++col )
     380             :         {
     381           4 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     382           4 :             if (const SmNode* node = pNode->GetSubNode(row * pNode->GetNumCols() + col))
     383           4 :                 HandleNode(node, nLevel + 1);
     384           4 :             m_pBuffer->append("}"); // me
     385             :         }
     386           2 :         m_pBuffer->append("}"); // mmr
     387             :     }
     388           1 :     m_pBuffer->append("}"); // mm
     389           1 : }
     390             : 
     391          23 : void SmRtfExport::HandleBrace(const SmBraceNode* pNode, int nLevel)
     392             : {
     393          23 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MD " ");
     394          23 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MDPR " ");
     395          23 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MBEGCHR " ");
     396          23 :     m_pBuffer->append(mathSymbolToString(pNode->OpeningBrace(), m_nEncoding));
     397          23 :     m_pBuffer->append("}"); // mbegChr
     398          23 :     std::vector< const SmNode* > subnodes;
     399          23 :     if (pNode->Body()->GetType() == NBRACEBODY)
     400             :     {
     401          23 :         const SmBracebodyNode* body = static_cast<const SmBracebodyNode*>( pNode->Body());
     402          23 :         bool separatorWritten = false; // assume all separators are the same
     403          50 :         for (int i = 0; i < body->GetNumSubNodes(); ++i)
     404             :         {
     405          27 :             const SmNode* subnode = body->GetSubNode(i);
     406          27 :             if (subnode->GetType() == NMATH || subnode->GetType() == NMATHIDENT)
     407             :             { // do not write, but write what separator it is
     408           3 :                 const SmMathSymbolNode* math = static_cast<const SmMathSymbolNode*>(subnode);
     409           3 :                 if(!separatorWritten)
     410             :                 {
     411           2 :                     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MSEPCHR " ");
     412           2 :                     m_pBuffer->append(mathSymbolToString(math, m_nEncoding));
     413           2 :                     m_pBuffer->append("}"); // msepChr
     414           2 :                     separatorWritten = true;
     415             :                 }
     416             :             }
     417             :             else
     418          24 :                 subnodes.push_back(subnode);
     419             :         }
     420             :     }
     421             :     else
     422           0 :         subnodes.push_back(pNode->Body());
     423          23 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MENDCHR " ");
     424          23 :     m_pBuffer->append(mathSymbolToString(pNode->ClosingBrace(), m_nEncoding));
     425          23 :     m_pBuffer->append("}"); // mendChr
     426          23 :     m_pBuffer->append("}"); // mdPr
     427          47 :     for (unsigned int i = 0; i < subnodes.size(); ++i)
     428             :     {
     429          24 :         m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     430          24 :         HandleNode(subnodes[ i ], nLevel + 1);
     431          24 :         m_pBuffer->append("}"); // me
     432             :     }
     433          23 :     m_pBuffer->append("}"); // md
     434          23 : }
     435             : 
     436           2 : void SmRtfExport::HandleVerticalBrace(const SmVerticalBraceNode* pNode, int nLevel)
     437             : {
     438             :     SAL_INFO("starmath.rtf", "Vertical: " << int(pNode->GetToken().eType));
     439           2 :     switch (pNode->GetToken().eType)
     440             :     {
     441             :         case TOVERBRACE:
     442             :         case TUNDERBRACE:
     443             :         {
     444           2 :             bool top = (pNode->GetToken().eType == TOVERBRACE);
     445           2 :             if (top)
     446           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMUPP " ");
     447             :             else
     448           1 :                 m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIMLOW " ");
     449           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     450           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHR " ");
     451           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MGROUPCHRPR " ");
     452           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MCHR " ");
     453           2 :             m_pBuffer->append(mathSymbolToString(pNode->Brace(), m_nEncoding));
     454           2 :             m_pBuffer->append("}"); // mchr
     455             :             // TODO not sure if pos and vertJc are correct
     456           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MPOS " ").append(top ? "top" : "bot").append("}");
     457           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MVERTJC " ").append(top ? "bot" : "top").append("}");
     458           2 :             m_pBuffer->append("}"); // mgroupChrPr
     459           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_ME " ");
     460           2 :             HandleNode(pNode->Body(), nLevel + 1);
     461           2 :             m_pBuffer->append("}"); // me
     462           2 :             m_pBuffer->append("}"); // mgroupChr
     463           2 :             m_pBuffer->append("}"); // me
     464           2 :             m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MLIM " ");
     465           2 :             HandleNode(pNode->Script(), nLevel + 1);
     466           2 :             m_pBuffer->append("}"); // mlim
     467           2 :             m_pBuffer->append("}"); // mlimUpp or mlimLow
     468           2 :             break;
     469             :         }
     470             :         default:
     471             :             SAL_INFO("starmath.rtf", "TODO: " << OSL_THIS_FUNC << " unhandled vertical brace type");
     472           0 :             break;
     473             :     }
     474           2 : }
     475             : 
     476           0 : void SmRtfExport::HandleBlank()
     477             : {
     478           0 :     m_pBuffer->append("{" LO_STRING_SVTOOLS_RTF_MR " ");
     479           0 :     m_pBuffer->append(" ");
     480           0 :     m_pBuffer->append("}"); // mr
     481          21 : }
     482             : 
     483             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10