LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/ww8 - rtfattributeoutput.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 758 1867 40.6 %
Date: 2012-12-17 Functions: 86 164 52.4 %
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             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "sal/config.h"
      21             : 
      22             : #include <cstring>
      23             : 
      24             : #include "rtfattributeoutput.hxx"
      25             : #include "rtfsdrexport.hxx"
      26             : #include "writerwordglue.hxx"
      27             : #include "ww8par.hxx"
      28             : #include "fmtcntnt.hxx"
      29             : #include "fchrfmt.hxx"
      30             : 
      31             : #include <rtl/ustring.hxx>
      32             : #include <svtools/rtfkeywd.hxx>
      33             : 
      34             : #include <editeng/fontitem.hxx>
      35             : #include <editeng/tstpitem.hxx>
      36             : #include <editeng/adjitem.hxx>
      37             : #include <editeng/spltitem.hxx>
      38             : #include <editeng/widwitem.hxx>
      39             : #include <editeng/keepitem.hxx>
      40             : #include <editeng/brshitem.hxx>
      41             : #include <editeng/postitem.hxx>
      42             : #include <editeng/wghtitem.hxx>
      43             : #include <editeng/kernitem.hxx>
      44             : #include <editeng/crsditem.hxx>
      45             : #include <editeng/cmapitem.hxx>
      46             : #include <editeng/wrlmitem.hxx>
      47             : #include <editeng/udlnitem.hxx>
      48             : #include <editeng/langitem.hxx>
      49             : #include <editeng/escpitem.hxx>
      50             : #include <editeng/fhgtitem.hxx>
      51             : #include <editeng/colritem.hxx>
      52             : #include <editeng/hyznitem.hxx>
      53             : #include <editeng/ulspitem.hxx>
      54             : #include <editeng/boxitem.hxx>
      55             : #include <editeng/cntritem.hxx>
      56             : #include <editeng/shdditem.hxx>
      57             : #include <editeng/akrnitem.hxx>
      58             : #include <editeng/emphitem.hxx>
      59             : #include <editeng/twolinesitem.hxx>
      60             : #include <editeng/charscaleitem.hxx>
      61             : #include <editeng/charrotateitem.hxx>
      62             : #include <editeng/charreliefitem.hxx>
      63             : #include <editeng/paravertalignitem.hxx>
      64             : #include <editeng/frmdiritem.hxx>
      65             : #include <editeng/blnkitem.hxx>
      66             : #include <editeng/charhiddenitem.hxx>
      67             : #include <svx/svdmodel.hxx>
      68             : #include <svx/fmglob.hxx>
      69             : #include <svx/svdouno.hxx>
      70             : #include <filter/msfilter/msoleexp.hxx>
      71             : #include <filter/msfilter/rtfutil.hxx>
      72             : #include <svtools/miscopt.hxx>
      73             : #include <sfx2/sfxbasemodel.hxx>
      74             : 
      75             : #include <docufld.hxx>
      76             : #include <fmtclds.hxx>
      77             : #include <fmtinfmt.hxx>
      78             : #include <fmtftn.hxx>
      79             : #include <fmtrowsplt.hxx>
      80             : #include <fmtline.hxx>
      81             : #include <fmtanchr.hxx>
      82             : #include <frmatr.hxx>
      83             : #include <htmltbl.hxx>
      84             : #include <ndgrf.hxx>
      85             : #include <ndtxt.hxx>
      86             : #include <pagedesc.hxx>
      87             : #include <swmodule.hxx>
      88             : #include <swtable.hxx>
      89             : #include <txtftn.hxx>
      90             : #include <txtinet.hxx>
      91             : #include <grfatr.hxx>
      92             : #include <ndole.hxx>
      93             : #include <lineinfo.hxx>
      94             : #include <rtf.hxx>
      95             : 
      96             : #include <vcl/cvtgrf.hxx>
      97             : #include <oox/mathml/export.hxx>
      98             : 
      99             : #include <com/sun/star/i18n/ScriptType.hpp>
     100             : 
     101             : using ::editeng::SvxBorderLine;
     102             : using namespace nsSwDocInfoSubType;
     103             : using namespace nsFieldFlags;
     104             : using namespace sw::util;
     105             : using namespace ::com::sun::star;
     106             : 
     107           6 : static OString OutTBLBorderLine(RtfExport &rExport, const SvxBorderLine* pLine, const sal_Char* pStr)
     108             : {
     109           6 :     OStringBuffer aRet;
     110           6 :     if ( !pLine->isEmpty() )
     111             :     {
     112           6 :         aRet.append(pStr);
     113             :         // single line
     114           6 :         switch (pLine->GetBorderLineStyle())
     115             :         {
     116             :             case table::BorderLineStyle::SOLID:
     117             :                 {
     118           6 :                     if( DEF_LINE_WIDTH_0 == pLine->GetWidth() )
     119           6 :                         aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRHAIR);
     120             :                     else
     121           0 :                         aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRS);
     122             :                 }
     123           6 :                 break;
     124             :             case table::BorderLineStyle::DOTTED:
     125           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDOT);
     126           0 :                 break;
     127             :             case table::BorderLineStyle::DASHED:
     128           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDASH);
     129           0 :                 break;
     130             :             case table::BorderLineStyle::DOUBLE:
     131           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDB);
     132           0 :                 break;
     133             :             case table::BorderLineStyle::THINTHICK_SMALLGAP:
     134           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHSG);
     135           0 :                 break;
     136             :             case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
     137           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHMG);
     138           0 :                 break;
     139             :             case table::BorderLineStyle::THINTHICK_LARGEGAP:
     140           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTNTHLG);
     141           0 :                 break;
     142             :             case table::BorderLineStyle::THICKTHIN_SMALLGAP:
     143           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNSG);
     144           0 :                 break;
     145             :             case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
     146           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNMG);
     147           0 :                 break;
     148             :             case table::BorderLineStyle::THICKTHIN_LARGEGAP:
     149           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTHTNLG);
     150           0 :                 break;
     151             :             case table::BorderLineStyle::EMBOSSED:
     152           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDREMBOSS);
     153           0 :                 break;
     154             :             case table::BorderLineStyle::ENGRAVED:
     155           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRENGRAVE);
     156           0 :                 break;
     157             :             case table::BorderLineStyle::OUTSET:
     158           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDROUTSET);
     159           0 :                 break;
     160             :             case table::BorderLineStyle::INSET:
     161           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRINSET);
     162           0 :                 break;
     163             :             case table::BorderLineStyle::NONE:
     164             :             default:
     165           0 :                 aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRNONE);
     166           0 :                 break;
     167             :         }
     168             : 
     169             :         double const fConverted( ::editeng::ConvertBorderWidthToWord(
     170           6 :                     pLine->GetBorderLineStyle(), pLine->GetWidth()) );
     171           6 :         if ( 255 >= pLine->GetWidth() ) // That value comes from RTF specs
     172             :         {
     173           6 :             aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW).append(
     174          12 :                     static_cast<sal_Int32>(fConverted));
     175             :         }
     176             :         else
     177             :         {   // use \brdrth to double the value range...
     178           0 :             aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH OOO_STRING_SVTOOLS_RTF_BRDRW);
     179           0 :             aRet.append(static_cast<sal_Int32>(fConverted) / 2);
     180             :         }
     181             : 
     182           6 :         aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF);
     183           6 :         aRet.append((sal_Int32)rExport.GetColor(pLine->GetColor()));
     184             :     }
     185           6 :     return aRet.makeStringAndClear();
     186             : }
     187             : 
     188           6 : static OString OutBorderLine(RtfExport &rExport, const SvxBorderLine* pLine,
     189             :     const sal_Char* pStr, sal_uInt16 nDist)
     190             : {
     191           6 :     OStringBuffer aRet;
     192           6 :     aRet.append(OutTBLBorderLine(rExport, pLine, pStr));
     193           6 :     aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP);
     194           6 :     aRet.append((sal_Int32)nDist);
     195           6 :     return aRet.makeStringAndClear();
     196             : }
     197             : 
     198         146 : void RtfAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
     199             : {
     200             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     201             :     /*
     202             :        You would have thought that
     203             :        m_rExport.Strm() << (bIsRTL ? OOO_STRING_SVTOOLS_RTF_RTLCH : OOO_STRING_SVTOOLS_RTF_LTRCH); would be sufficent here ,
     204             :        but looks like word needs to see the other directional token to be
     205             :        satisified that all is kosher, otherwise it seems in ver 2003 to go and
     206             :        semi-randomlyly stick strike through about the place. Perhaps
     207             :        strikethrough is some ms developers "something is wrong signal" debugging
     208             :        code that we're triggering ?
     209             :        */
     210         146 :     if (bIsRTL) {
     211           0 :         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
     212           0 :         m_aStylesEnd.append(' ');
     213           0 :         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
     214             :     } else {
     215         146 :         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
     216         146 :         m_aStylesEnd.append(' ');
     217         146 :         m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
     218             :     }
     219             : 
     220         146 :     switch (nScript) {
     221             :         case i18n::ScriptType::LATIN:
     222          86 :             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
     223          86 :             break;
     224             :         case i18n::ScriptType::ASIAN:
     225           0 :             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_DBCH);
     226           0 :             break;
     227             :         case i18n::ScriptType::COMPLEX:
     228             :             /* noop */
     229           0 :             break;
     230             :         default:
     231             :             /* should not happen? */
     232          60 :             break;
     233             :     }
     234         146 : }
     235             : 
     236         132 : void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
     237             : {
     238             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     239             : 
     240             :     // Output table/table row/table cell starts if needed
     241         132 :     if ( pTextNodeInfo.get() )
     242             :     {
     243           0 :         sal_uInt32 nRow = pTextNodeInfo->getRow();
     244           0 :         sal_uInt32 nCell = pTextNodeInfo->getCell();
     245             : 
     246             :         // New cell/row?
     247           0 :         if ( m_nTableDepth > 0 && !m_bTableCellOpen )
     248             :         {
     249           0 :             ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) );
     250             :             OSL_ENSURE( pDeepInner, "TableNodeInfoInner not found");
     251             :             // Make sure we always start a row between ending one and starting a cell.
     252             :             // In case of subtables, we may not get the first cell.
     253           0 :             if (pDeepInner && (pDeepInner->getCell() == 0 || m_bTableRowEnded))
     254             :             {
     255           0 :                 m_bTableRowEnded = false;
     256           0 :                 StartTableRow( pDeepInner );
     257             :             }
     258             : 
     259           0 :             StartTableCell( pDeepInner );
     260             :         }
     261             : 
     262             :         // Again, if depth was incremented, start a new table even if we skipped the first cell.
     263           0 :         if ((nRow == 0 && nCell == 0) || (m_nTableDepth == 0 && pTextNodeInfo->getDepth()))
     264             :         {
     265             :             // Do we have to start the table?
     266             :             // [If we are at the rigth depth already, it means that we
     267             :             // continue the table cell]
     268           0 :             sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
     269             : 
     270           0 :             if ( nCurrentDepth > m_nTableDepth )
     271             :             {
     272             :                 // Start all the tables that begin here
     273           0 :                 for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth )
     274             :                 {
     275           0 :                     ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
     276             : 
     277           0 :                     m_bLastTable = (nDepth == pTextNodeInfo->getDepth());
     278           0 :                     StartTable( pInner );
     279           0 :                     StartTableRow( pInner );
     280           0 :                     StartTableCell( pInner );
     281           0 :                 }
     282             : 
     283           0 :                 m_nTableDepth = nCurrentDepth;
     284             :             }
     285             :         }
     286             :     }
     287             : 
     288             :     OSL_ENSURE(m_aRun.getLength() == 0, "m_aRun is not empty");
     289         132 : }
     290             : 
     291         132 : void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
     292             : {
     293             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     294             : 
     295         132 :     FinishTableRowCell( pTextNodeInfoInner );
     296             : 
     297         132 :     RtfStringBuffer aParagraph;
     298             : 
     299         132 :     aParagraph.appendAndClear(m_aRun);
     300         132 :     aParagraph->append(m_aAfterRuns.makeStringAndClear());
     301         132 :     if (m_bTblAfterCell)
     302           0 :         m_bTblAfterCell = false;
     303             :     else
     304             :     {
     305         132 :         aParagraph->append(m_rExport.sNewLine);
     306         132 :         aParagraph->append(OOO_STRING_SVTOOLS_RTF_PAR);
     307         132 :         aParagraph->append(' ');
     308             :     }
     309         132 :     if (m_nColBreakNeeded)
     310             :     {
     311           0 :         aParagraph->append(OOO_STRING_SVTOOLS_RTF_COLUMN);
     312           0 :         m_nColBreakNeeded = false;
     313             :     }
     314             : 
     315         132 :     if (!m_bBufferSectionHeaders)
     316         130 :         aParagraph.makeStringAndClear(this);
     317             :     else
     318           2 :         m_aSectionHeaders.append(aParagraph.makeStringAndClear());
     319         132 : }
     320             : 
     321           0 : void RtfAttributeOutput::EmptyParagraph()
     322             : {
     323             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     324             : 
     325           0 :     m_rExport.Strm() << m_rExport.sNewLine << OOO_STRING_SVTOOLS_RTF_PAR << ' ';
     326           0 : }
     327             : 
     328         132 : void RtfAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode )
     329             : {
     330             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     331             :     OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
     332             : 
     333             :     // output page/section breaks
     334         132 :     SwNodeIndex aNextIndex( rNode, 1 );
     335         132 :     m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
     336         132 :     m_bBufferSectionBreaks = true;
     337             : 
     338             :     // output section headers / footers
     339         132 :     if (!m_bBufferSectionHeaders)
     340         130 :         m_rExport.Strm() << m_aSectionHeaders.makeStringAndClear().getStr();
     341             : 
     342         132 :     if ( aNextIndex.GetNode().IsTxtNode() )
     343             :     {
     344          68 :         const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
     345          68 :         m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode );
     346             :         // Save the current page description for now, so later we will be able to access the previous one.
     347          68 :         m_pPrevPageDesc = pTxtNode->FindPageDesc(sal_False);
     348             :     }
     349          64 :     else if ( aNextIndex.GetNode().IsTableNode() )
     350             :     {
     351           0 :         const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
     352           0 :         const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
     353           0 :         m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
     354             :     }
     355         132 :     m_bBufferSectionBreaks = false;
     356             : 
     357         132 :     OStringBuffer aPar;
     358         132 :     if (!m_rExport.bRTFFlySyntax)
     359             :     {
     360         124 :         aPar.append(OOO_STRING_SVTOOLS_RTF_PARD);
     361         124 :         aPar.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
     362         124 :         aPar.append(' ');
     363             :     }
     364         132 :     if (!m_bBufferSectionHeaders)
     365         130 :         m_rExport.Strm() << aPar.makeStringAndClear().getStr();
     366             :     else
     367           2 :         m_aSectionHeaders.append(aPar.makeStringAndClear());
     368         132 : }
     369             : 
     370         132 : void RtfAttributeOutput::EndParagraphProperties()
     371             : {
     372             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     373         132 :     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
     374         132 :     m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
     375         132 : }
     376             : 
     377         146 : void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun )
     378             : {
     379             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", bSingleEmptyRun: " << bSingleEmptyRun);
     380             : 
     381         146 :     m_bInRun = true;
     382         146 :     m_bSingleEmptyRun = bSingleEmptyRun;
     383         146 :     if (!m_bSingleEmptyRun)
     384         102 :         m_aRun->append('{');
     385             : 
     386             :     // if there is some redlining in the document, output it
     387         146 :     Redline( pRedlineData );
     388             : 
     389             :     OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
     390         146 : }
     391             : 
     392         146 : void RtfAttributeOutput::EndRun()
     393             : {
     394             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     395         146 :     m_aRun->append(m_rExport.sNewLine);
     396         146 :     m_aRun.appendAndClear(m_aRunText);
     397         146 :     if (!m_bSingleEmptyRun && m_bInRun)
     398         102 :         m_aRun->append('}');
     399         146 :     m_bInRun = false;
     400         146 : }
     401             : 
     402         146 : void RtfAttributeOutput::StartRunProperties()
     403             : {
     404             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     405             :     OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
     406         146 : }
     407             : 
     408         146 : void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
     409             : {
     410             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     411         146 :     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
     412         146 :     m_aRun->append(m_aStyles.makeStringAndClear());
     413         146 : }
     414             : 
     415          38 : void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding /*eCharSet*/ )
     416             : {
     417             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", rText: " << rText);
     418          38 :     RawText( rText, 0, m_rExport.eCurrentEncoding );
     419          38 : }
     420             : 
     421          48 : OStringBuffer& RtfAttributeOutput::RunText()
     422             : {
     423          48 :     return m_aRunText.getLastBuffer();
     424             : }
     425             : 
     426           0 : OStringBuffer& RtfAttributeOutput::Styles()
     427             : {
     428           0 :     return m_aStyles;
     429             : }
     430             : 
     431          38 : void RtfAttributeOutput::RawText( const String& rText, bool /*bForceUnicode*/, rtl_TextEncoding eCharSet )
     432             : {
     433             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     434          38 :     m_aRunText->append(msfilter::rtfutil::OutString(rText, eCharSet));
     435          38 : }
     436             : 
     437           0 : void RtfAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, xub_StrLen /*nPos*/, const SwFmtRuby& /*rRuby*/ )
     438             : {
     439             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
     440           0 : }
     441             : 
     442           0 : void RtfAttributeOutput::EndRuby()
     443             : {
     444             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
     445           0 : }
     446             : 
     447           0 : bool RtfAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
     448             : {
     449             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     450             : 
     451           0 :     m_aStyles.append('{');
     452           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD);
     453           0 :     m_aStyles.append('{');
     454           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
     455           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
     456           0 :     m_aStyles.append(" HYPERLINK ");
     457             : 
     458           0 :     String sURL( rUrl );
     459           0 :     if( sURL.Len() )
     460             :     {
     461           0 :         m_aStyles.append("\"");
     462           0 :         m_aStyles.append(msfilter::rtfutil::OutString( sURL, m_rExport.eCurrentEncoding));
     463           0 :         m_aStyles.append("\" ");
     464             :     }
     465             : 
     466           0 :     if( rTarget.Len() )
     467             :     {
     468           0 :         m_aStyles.append("\\\\t \"");
     469           0 :         m_aStyles.append(msfilter::rtfutil::OutString( rTarget, m_rExport.eCurrentEncoding));
     470           0 :         m_aStyles.append("\" ");
     471             :     }
     472             : 
     473           0 :     m_aStyles.append("}");
     474           0 :     m_bHadFieldResult = false;
     475           0 :     return true;
     476             : }
     477             : 
     478           0 : bool RtfAttributeOutput::EndURL()
     479             : {
     480             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     481             : 
     482             :     // close the fldrslt group
     483           0 :     if (m_bHadFieldResult)
     484           0 :         m_aRunText->append('}');
     485             :     // close the field group
     486           0 :     m_aRunText->append('}');
     487           0 :     return true;
     488             : }
     489             : 
     490           0 : void RtfAttributeOutput::FieldVanish( const String& /*rTxt*/, ww::eField /*eType*/ )
     491             : {
     492             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
     493           0 : }
     494             : 
     495         146 : void RtfAttributeOutput::Redline( const SwRedlineData* pRedline )
     496             : {
     497         146 :     if (!pRedline)
     498         292 :         return;
     499             : 
     500             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     501             : 
     502           0 :     if (pRedline->GetType() == nsRedlineType_t::REDLINE_INSERT)
     503             :     {
     504           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVISED);
     505           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
     506           0 :         m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
     507           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
     508             :     }
     509           0 :     else if(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
     510             :     {
     511           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_DELETED);
     512           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
     513           0 :         m_aRun->append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
     514           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
     515             :     }
     516           0 :     m_aRun->append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
     517           0 :     m_aRun->append(' ');
     518             : }
     519             : 
     520           0 : void RtfAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, sal_uInt16 /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t /*pTextNodeInfoInner*/ )
     521             : {
     522             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
     523           0 : }
     524             : 
     525         132 : void RtfAttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
     526             : {
     527             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     528             : 
     529         132 :     OString *pStyle = m_rExport.GetStyle(nStyle);
     530         132 :     OStringBuffer aStyle;
     531         132 :     aStyle.append(OOO_STRING_SVTOOLS_RTF_S);
     532         132 :     aStyle.append((sal_Int32)nStyle);
     533         132 :     if (pStyle)
     534         132 :         aStyle.append(pStyle->getStr());
     535         132 :     if (!m_bBufferSectionHeaders)
     536         130 :         m_rExport.Strm() << aStyle.makeStringAndClear().getStr();
     537             :     else
     538           2 :         m_aSectionHeaders.append(aStyle.makeStringAndClear());
     539         132 : }
     540             : 
     541           0 : void RtfAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
     542             : {
     543             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     544             : 
     545           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_INTBL);
     546           0 :     if ( m_nTableDepth > 1 )
     547             :     {
     548           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ITAP);
     549           0 :         m_aStyles.append((sal_Int32)m_nTableDepth);
     550             :     }
     551           0 :     m_bWroteCellInfo = true;
     552           0 : }
     553             : 
     554           0 : void RtfAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
     555             : {
     556             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     557             : 
     558             :     /* noop */
     559           0 : }
     560             : 
     561           0 : void RtfAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     562             : {
     563             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     564             : 
     565           0 :     if ( !m_pTableWrt )
     566           0 :         InitTableHelper( pTableTextNodeInfoInner );
     567             : 
     568           0 :     const SwTable *pTbl = pTableTextNodeInfoInner->getTable();
     569           0 :     SwFrmFmt *pFmt = pTbl->GetFrmFmt( );
     570             : 
     571           0 :     m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TROWD);
     572           0 :     TableOrientation( pTableTextNodeInfoInner );
     573           0 :     TableBidi( pTableTextNodeInfoInner );
     574           0 :     TableHeight( pTableTextNodeInfoInner );
     575           0 :     TableCanSplit( pTableTextNodeInfoInner );
     576             : 
     577             :     // Cell margins
     578           0 :     const SvxBoxItem& rBox = pFmt->GetBox( );
     579             :     static const sal_uInt16 aBorders[] =
     580             :     {
     581             :         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
     582             :     };
     583             : 
     584             :     static const char* aRowPadNames[] =
     585             :     {
     586             :         OOO_STRING_SVTOOLS_RTF_TRPADDT, OOO_STRING_SVTOOLS_RTF_TRPADDL, OOO_STRING_SVTOOLS_RTF_TRPADDB, OOO_STRING_SVTOOLS_RTF_TRPADDR
     587             :     };
     588             : 
     589             :     static const char* aRowPadUnits[] =
     590             :     {
     591             :         OOO_STRING_SVTOOLS_RTF_TRPADDFT, OOO_STRING_SVTOOLS_RTF_TRPADDFL, OOO_STRING_SVTOOLS_RTF_TRPADDFB, OOO_STRING_SVTOOLS_RTF_TRPADDFR
     592             :     };
     593             : 
     594           0 :     for (int i = 0; i < 4; ++i)
     595             :     {
     596           0 :         m_aRowDefs.append(aRowPadUnits[i]);
     597           0 :         m_aRowDefs.append((sal_Int32)3);
     598           0 :         m_aRowDefs.append(aRowPadNames[i]);
     599           0 :         m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
     600             :     }
     601             : 
     602             :     // The cell-dependent properties
     603           0 :     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
     604           0 :     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
     605           0 :     SwTwips nSz = 0;
     606           0 :     Point aPt;
     607           0 :     SwRect aRect( pFmt->FindLayoutRect( false, &aPt ));
     608           0 :     SwTwips nPageSize = aRect.Width();
     609             : 
     610             :     // Handle the page size when not rendered
     611           0 :     if( 0 == nPageSize )
     612             :     {
     613           0 :         const SwNode* pNode = pTableTextNodeInfoInner->getNode();
     614           0 :         const SwFrmFmt* pFrmFmt = GetExport().mpParentFrame ? &GetExport().mpParentFrame->GetFrmFmt() :
     615           0 :             GetExport().pDoc->GetPageDesc(0).GetPageFmtOfNode(*pNode, false);
     616             : 
     617           0 :         const SvxLRSpaceItem& rLR = pFrmFmt->GetLRSpace();
     618           0 :         nPageSize = pFrmFmt->GetFrmSize().GetWidth() -
     619           0 :                         rLR.GetLeft() - rLR.GetRight();
     620             :     }
     621           0 :     SwTwips nTblSz = pFmt->GetFrmSize().GetWidth();
     622             :     // Not using m_nTableDepth, which is not yet incremented here.
     623           0 :     sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
     624           0 :     m_aCells[nCurrentDepth] = pRow->GetCells().size();
     625           0 :     for( sal_uInt16 i = 0; i < m_aCells[nCurrentDepth]; i++ )
     626             :     {
     627           0 :         const SwWriteTableCell *pCell = &pRow->GetCells( )[ i ];
     628           0 :         const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
     629             : 
     630           0 :         pTableTextNodeInfoInner->setCell( i );
     631           0 :         TableCellProperties(pTableTextNodeInfoInner);
     632             : 
     633             :         // Right boundary: this can't be in TableCellProperties as the old
     634             :         // value of nSz is needed.
     635           0 :         nSz += pCellFmt->GetFrmSize().GetWidth();
     636           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
     637           0 :         SwTwips nCalc = nSz;
     638           0 :         nCalc *= nPageSize;
     639           0 :         nCalc /= nTblSz;
     640           0 :         m_aRowDefs.append( (sal_Int32)(pFmt->GetLRSpace().GetLeft() + nCalc) );
     641             :     }
     642           0 : }
     643             : 
     644           0 : void RtfAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     645             : {
     646             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     647             : 
     648             :     /*
     649             :      * The function name is a bit misleading: given that we write borders
     650             :      * before each row, we just have borders, not default ones. Additionally,
     651             :      * this function actually writes borders for a specific cell only and is
     652             :      * called for each cell.
     653             :      */
     654             : 
     655           0 :     const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
     656           0 :     SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
     657           0 :     const SvxBoxItem& rDefault = pFmt->GetBox( );
     658           0 :     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
     659           0 :     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
     660           0 :     const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
     661           0 :     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
     662             :     const SfxPoolItem* pItem;
     663           0 :     if (pCellFmt->GetAttrSet().HasItem(RES_BOX, &pItem))
     664             :     {
     665           0 :         const SvxBoxItem& rBox = (SvxBoxItem&)*pItem;
     666             :         static const sal_uInt16 aBorders[] =
     667             :         {
     668             :             BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
     669             :         };
     670             :         static const char* aBorderNames[] =
     671             :         {
     672             :             OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL, OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR
     673             :         };
     674             :         //Yes left and top are swapped with eachother for cell padding! Because
     675             :         //that's what the thunderingly annoying rtf export/import word xp does.
     676             :         static const char* aCellPadNames[] =
     677             :         {
     678             :             OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT, OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR
     679             :         };
     680             :         static const char* aCellPadUnits[] =
     681             :         {
     682             :             OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT, OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR
     683             :         };
     684           0 :         for (int i = 0; i < 4; ++i)
     685             :         {
     686           0 :             if (const SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
     687           0 :                 m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
     688           0 :             if (rDefault.GetDistance(aBorders[i]) !=
     689           0 :                     rBox.GetDistance(aBorders[i]))
     690             :             {
     691           0 :                 m_aRowDefs.append(aCellPadUnits[i]);
     692           0 :                 m_aRowDefs.append((sal_Int32)3);
     693           0 :                 m_aRowDefs.append(aCellPadNames[i]);
     694           0 :                 m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
     695             :             }
     696             :         }
     697             :     }
     698           0 : }
     699             : 
     700           0 : void RtfAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     701             : {
     702             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     703             : 
     704           0 :     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
     705           0 :     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
     706           0 :     const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
     707           0 :     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
     708             :     const SfxPoolItem* pItem;
     709           0 :     if (pCellFmt->GetAttrSet().HasItem(RES_BACKGROUND, &pItem))
     710             :     {
     711           0 :         const SvxBrushItem& rBack = (SvxBrushItem&)*pItem;
     712           0 :         if( !rBack.GetColor().GetTransparency() )
     713             :         {
     714           0 :             m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
     715           0 :             m_aRowDefs.append((sal_Int32)m_rExport.GetColor(rBack.GetColor()));
     716             :         }
     717             :     }
     718           0 : }
     719             : 
     720           0 : void RtfAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     721             : {
     722             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     723             : 
     724           0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
     725           0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
     726           0 :     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
     727           0 :     const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
     728             : 
     729           0 :     if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
     730             :     {
     731           0 :         sal_Int32 nHeight = 0;
     732             : 
     733           0 :         switch ( rLSz.GetHeightSizeType() )
     734             :         {
     735           0 :             case ATT_FIX_SIZE: nHeight = -rLSz.GetHeight(); break;
     736           0 :             case ATT_MIN_SIZE: nHeight = rLSz.GetHeight(); break;
     737           0 :             default:           break;
     738             :         }
     739             : 
     740           0 :         if ( nHeight )
     741             :         {
     742           0 :             m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
     743           0 :             m_aRowDefs.append(nHeight);
     744             :         }
     745             :     }
     746           0 : }
     747             : 
     748           0 : void RtfAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     749             : {
     750             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     751             : 
     752           0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
     753           0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
     754           0 :     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
     755           0 :     const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( );
     756             : 
     757             :     // The rtf default is to allow a row to break
     758           0 :     if (rSplittable.GetValue() == 0)
     759           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRKEEP);
     760           0 : }
     761             : 
     762           0 : void RtfAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     763             : {
     764             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     765             : 
     766           0 :     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
     767           0 :     const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
     768             : 
     769           0 :     if ( m_rExport.TrueFrameDirection( *pFrmFmt ) != FRMDIR_HORI_RIGHT_TOP )
     770           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_LTRROW);
     771             :     else
     772           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_RTLROW);
     773           0 : }
     774             : 
     775           0 : void RtfAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     776             : {
     777             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     778             : 
     779           0 :     const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
     780           0 :     SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
     781           0 :     const SwWriteTableCell *pCell = &pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
     782           0 :     const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
     783             :     const SfxPoolItem* pItem;
     784             : 
     785             :     // vertical merges
     786           0 :     if (pCell->GetRowSpan() > 1)
     787           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMGF);
     788           0 :     else if (pCell->GetRowSpan() == 0)
     789           0 :         m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
     790             : 
     791             :     // vertical alignment
     792           0 :     if (pCellFmt->GetAttrSet().HasItem(RES_VERT_ORIENT, &pItem))
     793           0 :         switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
     794             :         {
     795           0 :             case text::VertOrientation::CENTER: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC); break;
     796           0 :             case text::VertOrientation::BOTTOM: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB); break;
     797           0 :             default:                            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT); break;
     798             :         }
     799           0 : }
     800             : 
     801           0 : void RtfAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ )
     802             : {
     803             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     804             : 
     805             :     /* noop */
     806           0 : }
     807             : 
     808           0 : void RtfAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
     809             : {
     810             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     811             : 
     812             :     // This is called when the nested table ends in a cell, and there's no
     813             :     // paragraph benhind that; so we must check for the ends of cell, rows,
     814             :     // and tables
     815             :     // ['true' to write an empty paragraph, MS Word insists on that]
     816           0 :     FinishTableRowCell( pNodeInfoInner, true );
     817           0 : }
     818             : 
     819           0 : void RtfAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     820             : {
     821             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     822             : 
     823           0 :     const SwTable *pTable = pTableTextNodeInfoInner->getTable();
     824           0 :     SwFrmFmt *pFmt = pTable->GetFrmFmt( );
     825             : 
     826           0 :     OStringBuffer aTblAdjust( OOO_STRING_SVTOOLS_RTF_TRQL );
     827           0 :     switch (pFmt->GetHoriOrient().GetHoriOrient())
     828             :     {
     829             :         case text::HoriOrientation::CENTER:
     830           0 :             aTblAdjust.setLength(0);
     831           0 :             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQC);
     832           0 :             break;
     833             :         case text::HoriOrientation::RIGHT:
     834           0 :             aTblAdjust.setLength(0);
     835           0 :             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQR);
     836           0 :             break;
     837             :         case text::HoriOrientation::NONE:
     838             :         case text::HoriOrientation::LEFT_AND_WIDTH:
     839           0 :             aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRLEFT);
     840           0 :             aTblAdjust.append((sal_Int32)pFmt->GetLRSpace().GetLeft());
     841           0 :             break;
     842             :         default:
     843           0 :             break;
     844             :     }
     845             : 
     846           0 :     m_aRowDefs.append(aTblAdjust.makeStringAndClear());
     847           0 : }
     848             : 
     849           0 : void RtfAttributeOutput::TableSpacing( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
     850             : {
     851             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
     852           0 : }
     853             : 
     854           0 : void RtfAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
     855             : {
     856             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     857             : 
     858             :     /* noop, see EndTableRow() */
     859           0 : }
     860             : 
     861             : /*
     862             :  * Our private table methods.
     863             :  */
     864             : 
     865           0 : void RtfAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     866             : {
     867             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     868             : 
     869           0 :     sal_uInt32 nPageSize = 0;
     870           0 :     bool bRelBoxSize = false;
     871             : 
     872             :     // Create the SwWriteTable instance to use col spans
     873           0 :     GetTablePageSize( pTableTextNodeInfoInner.get(), nPageSize, bRelBoxSize );
     874             : 
     875           0 :     const SwTable* pTable = pTableTextNodeInfoInner->getTable( );
     876           0 :     const SwFrmFmt *pFmt = pTable->GetFrmFmt( );
     877           0 :     SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( );
     878             : 
     879           0 :     const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout();
     880           0 :     if( pLayout && pLayout->IsExportable() )
     881           0 :         m_pTableWrt = new SwWriteTable( pLayout );
     882             :     else
     883             :         m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (sal_uInt16)nPageSize,
     884           0 :                 (sal_uInt16)nTblSz, false);
     885           0 : }
     886             : 
     887           0 : void RtfAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
     888             : {
     889             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     890             : 
     891             :     // To trigger calling InitTableHelper()
     892           0 :     delete m_pTableWrt, m_pTableWrt = NULL;
     893           0 : }
     894             : 
     895           0 : void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     896             : {
     897           0 :     sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
     898             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << nCurrentDepth << ")");
     899             : 
     900           0 :     TableDefinition(pTableTextNodeInfoInner);
     901             : 
     902           0 :     SvtMiscOptions aMiscOptions;
     903           0 :     if (aMiscOptions.IsExperimentalMode())
     904             :     {
     905           0 :         m_aTables.push_back(m_aRowDefs.toString());
     906             :         // Emit row properties at the start of the row as well for non-nested
     907             :         // tables, to support old readers.
     908           0 :         if ( nCurrentDepth <= 1 )
     909           0 :             m_rExport.Strm() << m_aRowDefs.makeStringAndClear().getStr();
     910           0 :         m_aRowDefs.setLength(0);
     911             :         return;
     912             :     }
     913             :     else
     914             :     {
     915           0 :     if (!m_bLastTable)
     916           0 :         m_aTables.push_back(m_aRowDefs.makeStringAndClear());
     917             : 
     918             :     // We'll write the table definition for nested tables later
     919           0 :     if ( nCurrentDepth > 1 )
     920             :         return;
     921             :     // Empty the previous row closing buffer before starting the new one,
     922             :     // necessary for subtables.
     923           0 :     m_rExport.Strm() << m_aAfterRuns.makeStringAndClear().getStr();
     924           0 :     m_rExport.Strm() << m_aRowDefs.makeStringAndClear().getStr();
     925           0 :     }
     926             : }
     927             : 
     928           0 : void RtfAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
     929             : {
     930             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     931             : 
     932           0 :     m_bTableCellOpen = true;
     933           0 : }
     934             : 
     935           0 : void RtfAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
     936             : {
     937             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
     938             : 
     939           0 :     TableDefaultBorders(pTableTextNodeInfoInner);
     940           0 :     TableBackgrounds(pTableTextNodeInfoInner);
     941           0 :     TableVerticalCell(pTableTextNodeInfoInner);
     942           0 : }
     943             : 
     944           0 : void RtfAttributeOutput::EndTableCell( )
     945             : {
     946             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << m_nTableDepth << ")");
     947             : 
     948           0 :     if (!m_bWroteCellInfo)
     949             :     {
     950           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_INTBL);
     951           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ITAP);
     952           0 :         m_aAfterRuns.append((sal_Int32)m_nTableDepth);
     953             :     }
     954           0 :     if ( m_nTableDepth > 1 )
     955           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTCELL);
     956             :     else
     957           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
     958             : 
     959           0 :     m_bTableCellOpen = false;
     960           0 :     m_bTblAfterCell = true;
     961           0 :     m_bWroteCellInfo = false;
     962           0 :     if (m_aCells[m_nTableDepth] > 0)
     963           0 :         m_aCells[m_nTableDepth]--;
     964           0 : }
     965             : 
     966           0 : void RtfAttributeOutput::EndTableRow( )
     967             : {
     968             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", (depth is " << m_nTableDepth << ")");
     969             : 
     970             :     // Trying to end the row without writing the required number of cells? Fill with empty ones.
     971           0 :     for( sal_uInt16 i = 0; i < m_aCells[m_nTableDepth]; i++ )
     972           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
     973             : 
     974           0 :     if ( m_nTableDepth > 1 )
     975             :     {
     976           0 :         m_aAfterRuns.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
     977           0 :         if (m_aRowDefs.getLength() > 0)
     978           0 :             m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
     979           0 :         else if (!m_aTables.empty())
     980             :         {
     981           0 :             m_aAfterRuns.append(m_aTables.back());
     982           0 :             m_aTables.pop_back();
     983             :         }
     984           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTROW "}" "{" OOO_STRING_SVTOOLS_RTF_NONESTTABLES OOO_STRING_SVTOOLS_RTF_PAR "}");
     985             :     }
     986             :     else
     987             :     {
     988           0 :         if (!m_aTables.empty())
     989             :         {
     990           0 :             m_aAfterRuns.append(m_aTables.back());
     991           0 :             m_aTables.pop_back();
     992             :         }
     993           0 :         m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW).append(OOO_STRING_SVTOOLS_RTF_PARD);
     994             :     }
     995           0 :     m_bTableRowEnded = true;
     996           0 : }
     997             : 
     998           0 : void RtfAttributeOutput::EndTable()
     999             : {
    1000             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1001             : 
    1002           0 :     if ( m_nTableDepth > 0 ) {
    1003           0 :         m_nTableDepth--;
    1004           0 :         delete m_pTableWrt, m_pTableWrt = NULL;
    1005             :     }
    1006             : 
    1007             :     // We closed the table; if it is a nested table, the cell that contains it
    1008             :     // still continues
    1009           0 :     m_bTableCellOpen = true;
    1010             : 
    1011             :     // Cleans the table helper
    1012           0 :     delete m_pTableWrt, m_pTableWrt = NULL;
    1013           0 : }
    1014             : 
    1015         132 : void RtfAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool /*bForceEmptyParagraph*/ )
    1016             : {
    1017             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1018             : 
    1019         132 :     if ( pInner.get() )
    1020             :     {
    1021             :         // Where are we in the table
    1022           0 :         sal_uInt32 nRow = pInner->getRow( );
    1023             : 
    1024           0 :         const SwTable *pTable = pInner->getTable( );
    1025           0 :         const SwTableLines& rLines = pTable->GetTabLines( );
    1026           0 :         sal_uInt16 nLinesCount = rLines.size( );
    1027             : 
    1028           0 :         if ( pInner->isEndOfCell() )
    1029           0 :             EndTableCell();
    1030             : 
    1031             :         // This is a line end
    1032           0 :         if ( pInner->isEndOfLine() )
    1033           0 :             EndTableRow();
    1034             : 
    1035             :         // This is the end of the table
    1036           0 :         if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount )
    1037           0 :             EndTable();
    1038             :     }
    1039         132 : }
    1040             : 
    1041          56 : void RtfAttributeOutput::StartStyles()
    1042             : {
    1043             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1044          56 :     m_rExport.Strm() << m_rExport.sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL;
    1045          56 :     m_rExport.OutColorTable();
    1046             :     OSL_ENSURE(m_aStylesheet.getLength() == 0, "m_aStylesheet is not empty");
    1047          56 :     m_aStylesheet.append(m_rExport.sNewLine);
    1048          56 :     m_aStylesheet.append('{');
    1049          56 :     m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_STYLESHEET);
    1050          56 : }
    1051             : 
    1052          56 : void RtfAttributeOutput::EndStyles( sal_uInt16 /*nNumberOfStyles*/ )
    1053             : {
    1054             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1055          56 :     m_rExport.Strm() << '}';
    1056          56 :     m_rExport.Strm() << m_aStylesheet.makeStringAndClear().getStr();
    1057          56 :     m_rExport.Strm() << '}';
    1058          56 : }
    1059             : 
    1060         784 : void RtfAttributeOutput::DefaultStyle( sal_uInt16 /*nStyle*/ )
    1061             : {
    1062             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1063             : 
    1064             :     /* noop, the default style is always 0 in RTF */
    1065         784 : }
    1066             : 
    1067         348 : void RtfAttributeOutput::StartStyle( const String& rName, bool bPapFmt,
    1068             :         sal_uInt16 nBase, sal_uInt16 nNext, sal_uInt16 /*nWwId*/, sal_uInt16 nId,
    1069             :         bool /* bAutoUpdate */ )
    1070             : {
    1071             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", rName = '" << OUString(rName) << "'");
    1072             : 
    1073         348 :     m_aStylesheet.append('{');
    1074         348 :     if (bPapFmt)
    1075         340 :         m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_S);
    1076             :     else
    1077           8 :         m_aStylesheet.append( OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_CS);
    1078         348 :     m_aStylesheet.append( (sal_Int32)nId );
    1079             : 
    1080         348 :     if ( nBase != 0x0FFF )
    1081             :     {
    1082         284 :         m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SBASEDON);
    1083         284 :         m_aStylesheet.append((sal_Int32)nBase);
    1084             :     }
    1085             : 
    1086         348 :     m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SNEXT);
    1087         348 :     m_aStylesheet.append((sal_Int32)nNext);
    1088             : 
    1089         348 :     m_rStyleName = rName;
    1090         348 :     m_nStyleId = nId;
    1091         348 : }
    1092             : 
    1093         348 : void RtfAttributeOutput::EndStyle()
    1094             : {
    1095             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1096         348 :     m_aStyles.append(m_aStylesEnd.makeStringAndClear());
    1097         348 :     OString aStyles = m_aStyles.makeStringAndClear();
    1098         348 :     m_rExport.InsStyle(m_nStyleId, aStyles);
    1099         348 :     m_aStylesheet.append(aStyles);
    1100         348 :     m_aStylesheet.append(' ');
    1101         348 :     m_aStylesheet.append(msfilter::rtfutil::OutString(m_rStyleName, m_rExport.eCurrentEncoding));
    1102         348 :     m_aStylesheet.append(";}");
    1103         348 :     m_aStylesheet.append(m_rExport.sNewLine);
    1104         348 : }
    1105             : 
    1106         688 : void RtfAttributeOutput::StartStyleProperties( bool /*bParProp*/, sal_uInt16 /*nStyle*/ )
    1107             : {
    1108             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1109             :     /* noop */
    1110         688 : }
    1111             : 
    1112         688 : void RtfAttributeOutput::EndStyleProperties( bool /*bParProp*/ )
    1113             : {
    1114             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1115             :     /* noop */
    1116         688 : }
    1117             : 
    1118           0 : void RtfAttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ )
    1119             : {
    1120             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1121             : 
    1122           0 :     if ( nLvl >= WW8ListManager::nMaxLevel )
    1123           0 :         nLvl = WW8ListManager::nMaxLevel - 1;
    1124             : 
    1125           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
    1126           0 :     m_aStyles.append((sal_Int32)nLvl);
    1127           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTLINELEVEL);
    1128           0 :     m_aStyles.append((sal_Int32)nLvl);
    1129           0 : }
    1130             : 
    1131           0 : void RtfAttributeOutput::PageBreakBefore( bool bBreak )
    1132             : {
    1133             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1134             : 
    1135           0 :     if (bBreak)
    1136             :     {
    1137           0 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PAGEBB;
    1138             :     }
    1139           0 : }
    1140             : 
    1141           2 : void RtfAttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo )
    1142             : {
    1143             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1144             : 
    1145           2 :     switch (nC)
    1146             :     {
    1147             :         case msword::ColumnBreak:
    1148           0 :             m_nColBreakNeeded = true;
    1149           0 :             break;
    1150             :         case msword::PageBreak:
    1151           2 :             if ( pSectionInfo )
    1152           2 :                 m_rExport.SectionProperties( *pSectionInfo );
    1153           2 :             break;
    1154             :     }
    1155           2 : }
    1156             : 
    1157           2 : void RtfAttributeOutput::StartSection()
    1158             : {
    1159             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1160             : 
    1161           2 :     m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECT OOO_STRING_SVTOOLS_RTF_SECTD);
    1162           2 :     if (!m_bBufferSectionBreaks)
    1163           0 :         m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
    1164           2 : }
    1165             : 
    1166           2 : void RtfAttributeOutput::EndSection()
    1167             : {
    1168             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1169             : 
    1170             :     /*
    1171             :      * noop, \sect must go to StartSection or Word won't notice multiple
    1172             :      * columns...
    1173             :      */
    1174           2 : }
    1175             : 
    1176           2 : void RtfAttributeOutput::SectionFormProtection( bool bProtected )
    1177             : {
    1178             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1179             : 
    1180           2 :     m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
    1181           2 :     m_aSectionBreaks.append((sal_Int32)!bProtected);
    1182           2 : }
    1183             : 
    1184           0 : void RtfAttributeOutput::SectionLineNumbering( sal_uLong /*nRestartNo*/, const SwLineNumberInfo& rLnNumInfo )
    1185             : {
    1186             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1187             : 
    1188           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEMOD;
    1189           0 :     m_rExport.OutLong(rLnNumInfo.GetCountBy());
    1190           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEX;
    1191           0 :     m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
    1192           0 :     if (!rLnNumInfo.IsRestartEachPage())
    1193           0 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINECONT;
    1194           0 : }
    1195             : 
    1196           0 : void RtfAttributeOutput::SectionTitlePage()
    1197             : {
    1198             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1199             : 
    1200             :     /*
    1201             :      * noop, handled in RtfExport::WriteHeaderFooter()
    1202             :      */
    1203           0 : }
    1204             : 
    1205           2 : void RtfAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ )
    1206             : {
    1207             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1208             : 
    1209           2 :     const SvxBoxItem& rBox = pFmt->GetBox();
    1210           2 :     const SvxBorderLine *pLine = rBox.GetTop();
    1211           2 :     if(pLine)
    1212             :         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
    1213             :                     OOO_STRING_SVTOOLS_RTF_PGBRDRT,
    1214           0 :                     rBox.GetDistance(BOX_LINE_TOP) ));
    1215           2 :     pLine = rBox.GetBottom();
    1216           2 :     if(pLine)
    1217             :         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
    1218             :                     OOO_STRING_SVTOOLS_RTF_PGBRDRB,
    1219           0 :                     rBox.GetDistance(BOX_LINE_BOTTOM) ));
    1220           2 :     pLine = rBox.GetLeft();
    1221           2 :     if(pLine)
    1222             :         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
    1223             :                     OOO_STRING_SVTOOLS_RTF_PGBRDRL,
    1224           0 :                     rBox.GetDistance(BOX_LINE_LEFT) ));
    1225           2 :     pLine = rBox.GetRight();
    1226           2 :     if(pLine)
    1227             :         m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
    1228             :                     OOO_STRING_SVTOOLS_RTF_PGBRDRR,
    1229           0 :                     rBox.GetDistance(BOX_LINE_RIGHT) ));
    1230           2 : }
    1231             : 
    1232           0 : void RtfAttributeOutput::SectionBiDi( bool bBiDi )
    1233             : {
    1234             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1235             : 
    1236           0 :     m_rExport.Strm() << (bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT : OOO_STRING_SVTOOLS_RTF_LTRSECT);
    1237           0 : }
    1238             : 
    1239         124 : void RtfAttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, sal_uInt16 nPageRestartNumber )
    1240             : {
    1241             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1242             : 
    1243         124 :     if (nPageRestartNumber > 0)
    1244             :     {
    1245           0 :         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNSTARTS);
    1246           0 :         m_aSectionBreaks.append((sal_Int32)nPageRestartNumber);
    1247           0 :         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNRESTART);
    1248             :     }
    1249             : 
    1250         124 :     const char* pStr = 0;
    1251         124 :     switch ( nNumType )
    1252             :     {
    1253             :         case SVX_NUM_CHARS_UPPER_LETTER:
    1254           0 :         case SVX_NUM_CHARS_UPPER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNUCLTR; break;
    1255             :         case SVX_NUM_CHARS_LOWER_LETTER:
    1256           0 :         case SVX_NUM_CHARS_LOWER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNLCLTR; break;
    1257           0 :         case SVX_NUM_ROMAN_UPPER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNUCRM;  break;
    1258           0 :         case SVX_NUM_ROMAN_LOWER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNLCRM;  break;
    1259             : 
    1260         124 :         case SVX_NUM_ARABIC:                pStr = OOO_STRING_SVTOOLS_RTF_PGNDEC;     break;
    1261             :     }
    1262         124 :     if (pStr)
    1263         124 :         m_aSectionBreaks.append(pStr);
    1264         124 : }
    1265             : 
    1266           2 : void RtfAttributeOutput::SectionType( sal_uInt8 nBreakCode )
    1267             : {
    1268             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << ", nBreakCode = " << int(nBreakCode));
    1269             : 
    1270             :     /*
    1271             :      * break code:   0 No break, 1 New column
    1272             :      * 2 New page, 3 Even page, 4 Odd page
    1273             :      */
    1274           2 :     const char* sType = NULL;
    1275           2 :     switch ( nBreakCode )
    1276             :     {
    1277           0 :         case 1:  sType = OOO_STRING_SVTOOLS_RTF_SBKCOL; break;
    1278           2 :         case 2:  sType = OOO_STRING_SVTOOLS_RTF_SBKPAGE; break;
    1279           0 :         case 3:  sType = OOO_STRING_SVTOOLS_RTF_SBKEVEN; break;
    1280           0 :         case 4:  sType = OOO_STRING_SVTOOLS_RTF_SBKODD; break;
    1281           0 :         default: sType = OOO_STRING_SVTOOLS_RTF_SBKNONE; break;
    1282             :     }
    1283           2 :     m_aSectionBreaks.append(sType);
    1284           2 :     if (!m_bBufferSectionBreaks)
    1285           0 :         m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
    1286           2 : }
    1287             : 
    1288           0 : void RtfAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &/*rRule*/ )
    1289             : {
    1290             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1291             : 
    1292           0 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE;
    1293           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
    1294           0 :     m_rExport.OutULong(nId);
    1295           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT << '0';
    1296           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LS;
    1297           0 :     m_rExport.OutULong(nId) << '}';
    1298           0 : }
    1299             : 
    1300           0 : void RtfAttributeOutput::StartAbstractNumbering( sal_uInt16 nId )
    1301             : {
    1302             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1303             : 
    1304           0 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LIST << OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID;
    1305           0 :     m_rExport.OutULong( nId );
    1306           0 :     m_nListId = nId;
    1307           0 : }
    1308             : 
    1309           0 : void RtfAttributeOutput::EndAbstractNumbering()
    1310             : {
    1311             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1312             : 
    1313           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
    1314           0 :     m_rExport.OutULong( m_nListId ) << '}' << m_rExport.sNewLine;
    1315           0 : }
    1316             : 
    1317           0 : void RtfAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
    1318             :         sal_uInt16 nStart,
    1319             :         sal_uInt16 nNumberingType,
    1320             :         SvxAdjust eAdjust,
    1321             :         const sal_uInt8 * pNumLvlPos,
    1322             :         sal_uInt8 nFollow,
    1323             :         const wwFont * pFont,
    1324             :         const SfxItemSet * pOutSet,
    1325             :         sal_Int16 nIndentAt,
    1326             :         sal_Int16 nFirstLineIndex,
    1327             :         sal_Int16 /*nListTabPos*/,
    1328             :         const String &rNumberingString )
    1329             : {
    1330             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1331             : 
    1332           0 :     m_rExport.Strm() << m_rExport.sNewLine;
    1333           0 :     if( nLevel > 8 ) // RTF knows only 9 levels
    1334           0 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_SOUTLVL;
    1335             : 
    1336           0 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTLEVEL;
    1337             : 
    1338           0 :     sal_uInt16 nVal = 0;
    1339           0 :     switch( nNumberingType )
    1340             :     {
    1341           0 :         case SVX_NUM_ROMAN_UPPER:                   nVal = 1;       break;
    1342           0 :         case SVX_NUM_ROMAN_LOWER:                   nVal = 2;       break;
    1343             :         case SVX_NUM_CHARS_UPPER_LETTER:
    1344           0 :         case SVX_NUM_CHARS_UPPER_LETTER_N:  nVal = 3;       break;
    1345             :         case SVX_NUM_CHARS_LOWER_LETTER:
    1346           0 :         case SVX_NUM_CHARS_LOWER_LETTER_N:  nVal = 4;       break;
    1347             : 
    1348             :         case SVX_NUM_BITMAP:
    1349           0 :         case SVX_NUM_CHAR_SPECIAL:                  nVal = 23;      break;
    1350           0 :         case SVX_NUM_NUMBER_NONE:                   nVal = 255;     break;
    1351             :     }
    1352           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELNFC;
    1353           0 :     m_rExport.OutULong( nVal );
    1354             : 
    1355           0 :     switch( eAdjust )
    1356             :     {
    1357           0 :         case SVX_ADJUST_CENTER:             nVal = 1;       break;
    1358           0 :         case SVX_ADJUST_RIGHT:              nVal = 2;       break;
    1359           0 :         default:                            nVal = 0;       break;
    1360             :     }
    1361           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELJC;
    1362           0 :     m_rExport.OutULong( nVal );
    1363             : 
    1364           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT;
    1365           0 :     m_rExport.OutULong( nStart );
    1366             : 
    1367           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW;
    1368           0 :     m_rExport.OutULong( nFollow );
    1369             : 
    1370             :     // leveltext group
    1371           0 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LEVELTEXT << ' ';
    1372             : 
    1373           0 :     if( SVX_NUM_CHAR_SPECIAL == nNumberingType ||
    1374             :             SVX_NUM_BITMAP == nNumberingType )
    1375             :     {
    1376           0 :         m_rExport.Strm() << "\\'01";
    1377           0 :         sal_Unicode cChar = rNumberingString.GetChar(0);
    1378           0 :         m_rExport.Strm() << "\\u";
    1379           0 :         m_rExport.OutULong(cChar);
    1380           0 :         m_rExport.Strm() << " ?";
    1381             :     }
    1382             :     else
    1383             :     {
    1384           0 :         m_rExport.Strm() << "\\'" << msfilter::rtfutil::OutHex( rNumberingString.Len(), 2 ).getStr();
    1385           0 :         m_rExport.Strm() << msfilter::rtfutil::OutString( rNumberingString, m_rExport.eDefaultEncoding ).getStr();
    1386             :     }
    1387             : 
    1388           0 :     m_rExport.Strm() << ";}";
    1389             : 
    1390             :     // write the levelnumbers
    1391           0 :     m_rExport.Strm() << "{" << OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS;
    1392           0 :     for( sal_uInt8 i = 0; i <= nLevel && pNumLvlPos[ i ]; ++i )
    1393             :     {
    1394           0 :         m_rExport.Strm() << "\\'" << msfilter::rtfutil::OutHex(pNumLvlPos[ i ], 2).getStr();
    1395             :     }
    1396           0 :     m_rExport.Strm() << ";}";
    1397             : 
    1398           0 :     if( pOutSet )
    1399             :     {
    1400           0 :         if (pFont)
    1401             :         {
    1402           0 :             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_F;
    1403           0 :             m_rExport.OutULong(m_rExport.maFontHelper.GetId(*pFont));
    1404             :         }
    1405           0 :         m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN, m_rExport.mbExportModeRTF );
    1406           0 :         m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
    1407             :     }
    1408             : 
    1409           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FI;
    1410           0 :     m_rExport.OutLong( nFirstLineIndex ) << OOO_STRING_SVTOOLS_RTF_LI;
    1411           0 :     m_rExport.OutLong( nIndentAt );
    1412             : 
    1413           0 :     m_rExport.Strm() << '}';
    1414           0 :     if( nLevel > 8 )
    1415           0 :         m_rExport.Strm() << '}';
    1416           0 : }
    1417             : 
    1418           0 : void RtfAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField /*eType*/, const String& rFldCmd, sal_uInt8 /*nMode*/ )
    1419             : {
    1420             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1421             : 
    1422             :     // If there are no field instructions, don't export it as a field.
    1423           0 :     bool bHasInstructions = rFldCmd.Len() > 0;
    1424           0 :     if (bHasInstructions)
    1425             :     {
    1426           0 :         m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
    1427           0 :         m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
    1428           0 :         m_aRunText->append(msfilter::rtfutil::OutString(rFldCmd, m_rExport.eCurrentEncoding));
    1429           0 :         m_aRunText->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
    1430             :     }
    1431           0 :     if (pFld)
    1432           0 :         m_aRunText->append(msfilter::rtfutil::OutString(pFld->ExpandField(true), m_rExport.eDefaultEncoding));
    1433           0 :     if (bHasInstructions)
    1434           0 :         m_aRunText->append("}}");
    1435           0 : }
    1436             : 
    1437         278 : void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds )
    1438             : {
    1439         278 :     for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it != end; ++it )
    1440             :     {
    1441           0 :         m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
    1442           0 :         m_aRun->append(msfilter::rtfutil::OutString(*it, m_rExport.eCurrentEncoding));
    1443           0 :         m_aRun->append('}');
    1444             :     }
    1445         278 :     rStarts.clear();
    1446             : 
    1447         278 :     for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it != end; ++it )
    1448             :     {
    1449           0 :         m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
    1450           0 :         m_aRun->append(msfilter::rtfutil::OutString(*it, m_rExport.eCurrentEncoding));
    1451           0 :         m_aRun->append('}');
    1452             :     }
    1453         278 :     rEnds.clear();
    1454         278 : }
    1455             : 
    1456           0 : void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr, bool bTitlepg )
    1457             : {
    1458           0 :     OStringBuffer aSectionBreaks = m_aSectionBreaks;
    1459           0 :     m_aSectionBreaks.setLength(0);
    1460           0 :     RtfStringBuffer aRun = m_aRun;
    1461           0 :     m_aRun.clear();
    1462             : 
    1463           0 :     m_aSectionHeaders.append(bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
    1464           0 :     m_aSectionHeaders.append((sal_Int32)m_rExport.pAktPageDesc->GetMaster().GetULSpace().GetUpper());
    1465           0 :     if (bTitlepg)
    1466           0 :         m_aSectionHeaders.append(OOO_STRING_SVTOOLS_RTF_TITLEPG);
    1467           0 :     m_aSectionHeaders.append('{');
    1468           0 :     m_aSectionHeaders.append(pStr);
    1469           0 :     m_bBufferSectionHeaders = true;
    1470           0 :     m_rExport.WriteHeaderFooterText(rFmt, bHeader);
    1471           0 :     m_bBufferSectionHeaders = false;
    1472           0 :     m_aSectionHeaders.append('}');
    1473             : 
    1474           0 :     m_aSectionBreaks = aSectionBreaks;
    1475           0 :     m_aRun = aRun;
    1476           0 : }
    1477             : 
    1478          66 : void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& /*rNdTopLeft*/ )
    1479             : {
    1480             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1481             : 
    1482          66 :     const SwNode *pNode = rFrame.GetContent();
    1483          66 :     const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0;
    1484             : 
    1485          66 :     switch ( rFrame.GetWriterType() )
    1486             :     {
    1487             :         case sw::Frame::eTxtBox:
    1488             :             OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
    1489           6 :             m_rExport.mpParentFrame = &rFrame;
    1490           6 :             m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = true;
    1491           6 :             m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
    1492           6 :             m_rExport.Strm() << m_aRunText.makeStringAndClear().getStr();
    1493           6 :             m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
    1494           6 :             m_rExport.bOutFlyFrmAttrs = m_rExport.bRTFFlySyntax = false;
    1495           6 :             m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE;
    1496           6 :             m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
    1497           6 :             m_rExport.Strm() << m_aRunText.makeStringAndClear().getStr();
    1498           6 :             m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
    1499           6 :             m_rExport.Strm() << '}';
    1500             : 
    1501             :             {
    1502             :                 /*
    1503             :                  * Save m_aRun as we should not loose the opening brace.
    1504             :                  * OTOH, just drop the contents of m_aRunText in case something
    1505             :                  * would be there, causing a problem later.
    1506             :                  */
    1507           6 :                 OString aSave = m_aRun.makeStringAndClear();
    1508             :                 // Also back m_bInRun and m_bSingleEmptyRun up.
    1509           6 :                 bool bInRunOrig = m_bInRun;
    1510           6 :                 m_bInRun = false;
    1511           6 :                 bool bSingleEmptyRunOrig = m_bSingleEmptyRun;
    1512           6 :                 m_bSingleEmptyRun = false;
    1513           6 :                 m_rExport.bRTFFlySyntax = true;
    1514             : 
    1515           6 :                 const SwFrmFmt& rFrmFmt = rFrame.GetFrmFmt( );
    1516           6 :                 const SwNodeIndex* pNodeIndex = rFrmFmt.GetCntnt().GetCntntIdx();
    1517           6 :                 sal_uLong nStt = pNodeIndex ? pNodeIndex->GetIndex()+1                  : 0;
    1518           6 :                 sal_uLong nEnd = pNodeIndex ? pNodeIndex->GetNode().EndOfSectionIndex() : 0;
    1519           6 :                 m_rExport.SaveData( nStt, nEnd );
    1520           6 :                 m_rExport.mpParentFrame = &rFrame;
    1521           6 :                 m_rExport.WriteText( );
    1522           6 :                 m_rExport.RestoreData();
    1523             : 
    1524           6 :                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PARD;
    1525           6 :                 m_rExport.bRTFFlySyntax = false;
    1526           6 :                 m_aRun->append(aSave);
    1527           6 :                 m_aRunText.clear();
    1528           6 :                 m_bInRun = bInRunOrig;
    1529           6 :                 m_bSingleEmptyRun = bSingleEmptyRunOrig;
    1530             :             }
    1531             : 
    1532           6 :             m_rExport.mpParentFrame = NULL;
    1533           6 :             m_rExport.Strm() << RtfExport::sNewLine;
    1534           6 :             break;
    1535             :         case sw::Frame::eGraphic:
    1536           0 :             if (!rFrame.IsInline())
    1537             :             {
    1538           0 :                 m_rExport.mpParentFrame = &rFrame;
    1539           0 :                 m_rExport.bRTFFlySyntax = true;
    1540           0 :                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
    1541           0 :                 m_rExport.bRTFFlySyntax = false;
    1542           0 :                 m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
    1543           0 :                 m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
    1544           0 :                 m_aRunText->append('}');
    1545           0 :                 m_rExport.mpParentFrame = NULL;
    1546             :             }
    1547             : 
    1548           0 :             if ( pGrfNode )
    1549           0 :                 m_aRunText.append(dynamic_cast<const SwFlyFrmFmt*>( &rFrame.GetFrmFmt() ), pGrfNode);
    1550           0 :             break;
    1551             :         case sw::Frame::eDrawing:
    1552             :             {
    1553           2 :                 const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
    1554           2 :                 if ( pSdrObj )
    1555             :                 {
    1556           2 :                     bool bSwapInPage = false;
    1557           2 :                     if ( !pSdrObj->GetPage() )
    1558             :                     {
    1559           0 :                         if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
    1560             :                         {
    1561           0 :                             if ( SdrPage *pPage = pModel->GetPage( 0 ) )
    1562             :                             {
    1563           0 :                                 bSwapInPage = true;
    1564           0 :                                 const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
    1565             :                             }
    1566             :                         }
    1567             :                     }
    1568             : 
    1569           2 :                     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
    1570           2 :                     m_aRunText->append(OOO_STRING_SVTOOLS_RTF_IGNORE);
    1571           2 :                     m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLDINST);
    1572           2 :                     m_aRunText->append(" SHAPE ");
    1573           2 :                     m_aRunText->append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
    1574             : 
    1575           2 :                     m_rExport.SdrExporter().AddSdrObject( *pSdrObj );
    1576             : 
    1577           2 :                     m_aRunText->append('}');
    1578           2 :                     m_aRunText->append('}');
    1579             : 
    1580           2 :                     if ( bSwapInPage )
    1581           0 :                         const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
    1582             :                 }
    1583             :             }
    1584           2 :             break;
    1585             :         case sw::Frame::eFormControl:
    1586             :             {
    1587           0 :                 const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
    1588           0 :                 const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
    1589             : 
    1590           0 :                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
    1591           0 :                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
    1592             : 
    1593           0 :                 if (pObject && pObject->GetObjInventor() == FmFormInventor)
    1594             :                 {
    1595           0 :                     if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
    1596             :                     {
    1597             :                         uno::Reference< awt::XControlModel > xControlModel =
    1598           0 :                             pFormObj->GetUnoControlModel();
    1599           0 :                         uno::Reference< lang::XServiceInfo > xInfo(xControlModel, uno::UNO_QUERY);
    1600           0 :                         uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
    1601           0 :                         uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo();
    1602           0 :                         OUString sName;
    1603           0 :                         if (xInfo->supportsService("com.sun.star.form.component.CheckBox"))
    1604             :                         {
    1605             : 
    1606           0 :                             m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
    1607           0 :                             m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
    1608           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
    1609             :                             // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
    1610           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
    1611             : 
    1612           0 :                             OUString aStr;
    1613           0 :                             sName = "Name";
    1614           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1615             :                             {
    1616           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1617           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
    1618           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1619           0 :                                 m_aRun->append('}');
    1620             :                             }
    1621             : 
    1622           0 :                             sName = "HelpText";
    1623           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1624             :                             {
    1625           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1626           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
    1627           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
    1628           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1629           0 :                                 m_aRun->append('}');
    1630             :                             }
    1631             : 
    1632           0 :                             sName = "HelpF1Text";
    1633           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1634             :                             {
    1635           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1636           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
    1637           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
    1638           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1639           0 :                                 m_aRun->append('}');
    1640             :                             }
    1641             : 
    1642           0 :                             sal_Int16 nTemp = 0;
    1643           0 :                             xPropSet->getPropertyValue("DefaultState") >>= nTemp;
    1644           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
    1645           0 :                             m_aRun->append((sal_Int32)nTemp);
    1646           0 :                             xPropSet->getPropertyValue("State") >>= nTemp;
    1647           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
    1648           0 :                             m_aRun->append((sal_Int32)nTemp);
    1649             : 
    1650           0 :                             m_aRun->append("}}");
    1651             : 
    1652             :                             // field result is empty, ffres already contains the form result
    1653           0 :                             m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
    1654             :                         }
    1655           0 :                         else if (xInfo->supportsService("com.sun.star.form.component.TextField"))
    1656             :                         {
    1657           0 :                             OStringBuffer aBuf;
    1658           0 :                             OString aStr;
    1659           0 :                             OUString aTmp;
    1660             :                             const sal_Char* pStr;
    1661             : 
    1662           0 :                             m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
    1663           0 :                             m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
    1664           0 :                             for (int i = 0; i < 8; i++) aBuf.append((sal_Char)0x00);
    1665           0 :                             xPropSet->getPropertyValue("Name") >>= aTmp;
    1666           0 :                             aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
    1667           0 :                             aBuf.append((sal_Char)aStr.getLength());
    1668           0 :                             aBuf.append(aStr);
    1669           0 :                             aBuf.append((sal_Char)0x00);
    1670           0 :                             xPropSet->getPropertyValue("DefaultText") >>= aTmp;
    1671           0 :                             aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
    1672           0 :                             aBuf.append((sal_Char)aStr.getLength());
    1673           0 :                             aBuf.append(aStr);
    1674           0 :                             for (int i = 0; i < 11; i++) aBuf.append((sal_Char)0x00);
    1675           0 :                             aStr = aBuf.makeStringAndClear();
    1676           0 :                             pStr = aStr.getStr();
    1677           0 :                             for (int i = 0; i < aStr.getLength(); i++, pStr++)
    1678           0 :                                 m_aRun->append(msfilter::rtfutil::OutHex(*pStr, 2));
    1679           0 :                             m_aRun->append('}');
    1680           0 :                             m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
    1681           0 :                             xPropSet->getPropertyValue("Text") >>= aTmp;
    1682           0 :                             m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
    1683           0 :                             m_aRun->append('}');
    1684           0 :                             m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
    1685           0 :                             sName = "HelpText";
    1686           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1687             :                             {
    1688           0 :                                 xPropSet->getPropertyValue(sName) >>= aTmp;
    1689           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
    1690           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
    1691           0 :                                 m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
    1692           0 :                                 m_aRun->append('}');
    1693             :                             }
    1694             : 
    1695           0 :                             sName = "HelpF1Text";
    1696           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1697             :                             {
    1698           0 :                                 xPropSet->getPropertyValue(sName) >>= aTmp;
    1699           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
    1700           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
    1701           0 :                                 m_aRun->append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
    1702           0 :                                 m_aRun->append('}');
    1703             :                             }
    1704           0 :                             m_aRun->append("}");
    1705             :                         }
    1706           0 :                         else if (xInfo->supportsService("com.sun.star.form.component.ListBox"))
    1707             :                         {
    1708           0 :                             OUString aStr;
    1709           0 :                             uno::Sequence<sal_Int16> aIntSeq;
    1710           0 :                             uno::Sequence<OUString> aStrSeq;
    1711             : 
    1712           0 :                             m_aRun->append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
    1713           0 :                             m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
    1714           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
    1715           0 :                             m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
    1716             : 
    1717           0 :                             xPropSet->getPropertyValue("DefaultSelection") >>= aIntSeq;
    1718           0 :                             if( aIntSeq.getLength() )
    1719             :                             {
    1720           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
    1721             :                                 // a dropdown list can have only one 'selected item by default'
    1722           0 :                                 m_aRun->append((sal_Int32)aIntSeq[0]);
    1723             :                             }
    1724             : 
    1725           0 :                             xPropSet->getPropertyValue("SelectedItems") >>= aIntSeq;
    1726           0 :                             if( aIntSeq.getLength() )
    1727             :                             {
    1728           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFRES);
    1729             :                                 // a dropdown list can have only one 'currently selected item'
    1730           0 :                                 m_aRun->append((sal_Int32)aIntSeq[0]);
    1731             :                             }
    1732             : 
    1733           0 :                             sName = "Name";
    1734           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1735             :                             {
    1736           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1737           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
    1738           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1739           0 :                                 m_aRun->append('}');
    1740             :                             }
    1741             : 
    1742           0 :                             sName = "HelpText";
    1743           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1744             :                             {
    1745           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1746           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
    1747           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
    1748           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1749           0 :                                 m_aRun->append('}');
    1750             :                             }
    1751             : 
    1752           0 :                             sName = "HelpF1Text";
    1753           0 :                             if (xPropSetInfo->hasPropertyByName(sName))
    1754             :                             {
    1755           0 :                                 xPropSet->getPropertyValue(sName) >>= aStr;
    1756           0 :                                 m_aRun->append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
    1757           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
    1758           0 :                                 m_aRun->append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
    1759           0 :                                 m_aRun->append('}');
    1760             :                             }
    1761             : 
    1762             : 
    1763           0 :                             xPropSet->getPropertyValue("StringItemList") >>= aStrSeq;
    1764           0 :                             sal_uInt32 nListItems = aStrSeq.getLength();
    1765           0 :                             for (sal_uInt32 i = 0; i < nListItems; i++)
    1766           0 :                                 m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
    1767           0 :                                     .append(OUStringToOString(aStrSeq[i], m_rExport.eCurrentEncoding)).append('}');
    1768             : 
    1769           0 :                             m_aRun->append("}}");
    1770             : 
    1771             :                             // field result is empty, ffres already contains the form result
    1772           0 :                             m_aRun->append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
    1773             :                         }
    1774             :                         else
    1775             :                             SAL_INFO("sw.rtf", OSL_THIS_FUNC << " unhandled form control: '" << xInfo->getImplementationName()<< "'");
    1776           0 :                         m_aRun->append('}');
    1777             :                     }
    1778             :                 }
    1779             : 
    1780           0 :                 m_aRun->append('}');
    1781             :             }
    1782           0 :             break;
    1783             :         case sw::Frame::eOle:
    1784             :             {
    1785          58 :                 const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
    1786          58 :                 const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
    1787          58 :                 if ( pSdrObj )
    1788             :                 {
    1789          58 :                     SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
    1790          58 :                     SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
    1791          58 :                     FlyFrameOLE(dynamic_cast<const SwFlyFrmFmt*>( &rFrmFmt ), rOLENd, rFrame.GetLayoutSize());
    1792             :                 }
    1793             :             }
    1794          58 :             break;
    1795             :         default:
    1796             :             SAL_INFO("sw.rtf", OSL_THIS_FUNC << ": unknown type (" << (int)rFrame.GetWriterType() << ")");
    1797           0 :             break;
    1798             :     }
    1799          66 : }
    1800             : 
    1801           0 : void RtfAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
    1802             : {
    1803             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1804             : 
    1805           0 :     switch ( rCaseMap.GetValue() )
    1806             :     {
    1807             :         case SVX_CASEMAP_KAPITAELCHEN:
    1808           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
    1809           0 :             break;
    1810             :         case SVX_CASEMAP_VERSALIEN:
    1811           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
    1812           0 :             break;
    1813             :         default: // Something that rtf does not support
    1814           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
    1815           0 :             m_aStyles.append((sal_Int32)0);
    1816           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
    1817           0 :             m_aStyles.append((sal_Int32)0);
    1818           0 :             break;
    1819             :     }
    1820           0 : }
    1821             : 
    1822          56 : void RtfAttributeOutput::CharColor( const SvxColorItem& rColor )
    1823             : {
    1824             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1825             : 
    1826          56 :     const Color aColor( rColor.GetValue() );
    1827             : 
    1828          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CF);
    1829          56 :     m_aStyles.append( (sal_Int32)m_rExport.GetColor( aColor ));
    1830          56 : }
    1831             : 
    1832           0 : void RtfAttributeOutput::CharContour( const SvxContourItem& rContour )
    1833             : {
    1834             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1835             : 
    1836           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTL);
    1837           0 :     if ( !rContour.GetValue() )
    1838           0 :         m_aStyles.append((sal_Int32)0);
    1839           0 : }
    1840             : 
    1841           0 : void RtfAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut )
    1842             : {
    1843             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1844             : 
    1845           0 :     switch ( rCrossedOut.GetStrikeout() )
    1846             :     {
    1847             :         case STRIKEOUT_NONE:
    1848           0 :             if (!m_bStrikeDouble)
    1849           0 :                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
    1850             :             else
    1851           0 :                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
    1852           0 :             m_aStyles.append((sal_Int32)0);
    1853           0 :             break;
    1854             :         case STRIKEOUT_DOUBLE:
    1855           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
    1856           0 :             m_aStyles.append((sal_Int32)1);
    1857           0 :             break;
    1858             :         default:
    1859           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
    1860           0 :             break;
    1861             :     }
    1862           0 : }
    1863             : 
    1864           4 : void RtfAttributeOutput::CharEscapement( const SvxEscapementItem& rEsc )
    1865             : {
    1866             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1867             : 
    1868             :     const char * pUpDn;
    1869             : 
    1870           4 :     SwTwips nH = ((SvxFontHeightItem&)m_rExport.GetItem( RES_CHRATR_FONTSIZE )).GetHeight();
    1871             : 
    1872           4 :     if( 0 < rEsc.GetEsc() )
    1873           4 :         pUpDn = OOO_STRING_SVTOOLS_RTF_UP;
    1874           0 :     else if( 0 > rEsc.GetEsc() )
    1875             :     {
    1876           0 :         pUpDn = OOO_STRING_SVTOOLS_RTF_DN;
    1877           0 :         nH = -nH;
    1878             :     }
    1879             :     else
    1880           4 :         return;
    1881             : 
    1882           4 :     short nEsc = rEsc.GetEsc();
    1883           4 :     short nProp = rEsc.GetProp() * 100;
    1884           4 :     if( DFLT_ESC_AUTO_SUPER == nEsc )
    1885             :     {
    1886           4 :         nEsc = 100 - rEsc.GetProp();
    1887           4 :         ++nProp;
    1888             :     }
    1889           0 :     else if( DFLT_ESC_AUTO_SUB == nEsc )
    1890             :     {
    1891           0 :         nEsc = - 100 + rEsc.GetProp();
    1892           0 :         ++nProp;
    1893             :     }
    1894             : 
    1895           4 :     m_aStyles.append('{');
    1896           4 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
    1897           4 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_UPDNPROP);
    1898           4 :     m_aStyles.append( (sal_Int32)nProp );
    1899           4 :     m_aStyles.append('}');
    1900           4 :     m_aStyles.append(pUpDn);
    1901             : 
    1902             :     /*
    1903             :      * Calculate the act. FontSize and the percentage of the displacement;
    1904             :      * RTF file expects half points, while internally it's in twips.
    1905             :      * Formally :            (FontSize * 1/20 ) pts         x * 2
    1906             :      *                    -----------------------  = ------------
    1907             :      *                      100%                       Escapement
    1908             :      */
    1909             : 
    1910           4 :     m_aStyles.append( (sal_Int32) ( (long( nEsc ) * nH) + 500L ) / 1000L );
    1911             :     // 500L to round !!
    1912             : }
    1913             : 
    1914         260 : void RtfAttributeOutput::CharFont( const SvxFontItem& rFont)
    1915             : {
    1916             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1917             : 
    1918         260 :     m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
    1919         260 :     m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_F);
    1920         260 :     m_aStylesEnd.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
    1921         260 :     m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(rtl_getBestWindowsCharsetFromTextEncoding(rFont.GetCharSet()));
    1922         260 : }
    1923             : 
    1924         344 : void RtfAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
    1925             : {
    1926             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1927             : 
    1928         344 :     switch ( rFontSize.Which() )
    1929             :     {
    1930             :         case RES_CHRATR_FONTSIZE:
    1931         174 :             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_FS);
    1932         174 :             m_aStylesEnd.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
    1933         174 :             break;
    1934             :         case RES_CHRATR_CJK_FONTSIZE:
    1935           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FS);
    1936           0 :             m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
    1937           0 :             break;
    1938             :         case RES_CHRATR_CTL_FONTSIZE:
    1939         170 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AFS);
    1940         170 :             m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
    1941         170 :             break;
    1942             :     }
    1943         344 : }
    1944             : 
    1945           0 : void RtfAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
    1946             : {
    1947             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1948             : 
    1949             :     // in quater points then in twips
    1950           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPND);
    1951           0 :     m_aStyles.append((sal_Int32)(rKerning.GetValue() / 5));
    1952           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPNDTW);
    1953           0 :     m_aStyles.append((sal_Int32)(rKerning.GetValue()));
    1954           0 : }
    1955             : 
    1956         174 : void RtfAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
    1957             : {
    1958             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1959             : 
    1960         174 :     switch (rLanguage.Which())
    1961             :     {
    1962             :         case RES_CHRATR_LANGUAGE:
    1963          58 :             m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LANG);
    1964          58 :             m_aStylesEnd.append((sal_Int32)rLanguage.GetLanguage());
    1965          58 :             break;
    1966             :         case RES_CHRATR_CJK_LANGUAGE:
    1967          56 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANGFE);
    1968          56 :             m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
    1969          56 :             break;
    1970             :         case RES_CHRATR_CTL_LANGUAGE:
    1971          60 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ALANG);
    1972          60 :             m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
    1973          60 :             break;
    1974             :     }
    1975         174 : }
    1976             : 
    1977          56 : void RtfAttributeOutput::CharPosture( const SvxPostureItem& rPosture )
    1978             : {
    1979             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1980             : 
    1981          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
    1982          56 :     if ( rPosture.GetPosture() == ITALIC_NONE )
    1983           0 :         m_aStyles.append((sal_Int32)0);
    1984          56 : }
    1985             : 
    1986           0 : void RtfAttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
    1987             : {
    1988             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1989             : 
    1990           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SHAD);
    1991           0 :     if ( !rShadow.GetValue() )
    1992           0 :         m_aStyles.append((sal_Int32)0);
    1993           0 : }
    1994             : 
    1995           0 : void RtfAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
    1996             : {
    1997             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    1998             : 
    1999           0 :     const char* pStr = 0;
    2000           0 :     const SfxPoolItem* pItem = m_rExport.HasItem( RES_CHRATR_WORDLINEMODE );
    2001           0 :     bool bWord = false;
    2002           0 :     if (pItem)
    2003           0 :         bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false;
    2004           0 :     switch(rUnderline.GetLineStyle() )
    2005             :     {
    2006             :         case UNDERLINE_SINGLE:
    2007           0 :             pStr = bWord ? OOO_STRING_SVTOOLS_RTF_ULW : OOO_STRING_SVTOOLS_RTF_UL;
    2008           0 :             break;
    2009             :         case UNDERLINE_DOUBLE:
    2010           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULDB;
    2011           0 :             break;
    2012             :         case UNDERLINE_NONE:
    2013           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULNONE;
    2014           0 :             break;
    2015             :         case UNDERLINE_DOTTED:
    2016           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULD;
    2017           0 :             break;
    2018             :         case UNDERLINE_DASH:
    2019           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULDASH;
    2020           0 :             break;
    2021             :         case UNDERLINE_DASHDOT:
    2022           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULDASHD;
    2023           0 :             break;
    2024             :         case UNDERLINE_DASHDOTDOT:
    2025           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULDASHDD;
    2026           0 :             break;
    2027             :         case UNDERLINE_BOLD:
    2028           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTH;
    2029           0 :             break;
    2030             :         case UNDERLINE_WAVE:
    2031           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULWAVE;
    2032           0 :             break;
    2033             :         case UNDERLINE_BOLDDOTTED:
    2034           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTHD;
    2035           0 :             break;
    2036             :         case UNDERLINE_BOLDDASH:
    2037           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASH;
    2038           0 :             break;
    2039             :         case UNDERLINE_LONGDASH:
    2040           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULLDASH;
    2041           0 :             break;
    2042             :         case UNDERLINE_BOLDLONGDASH:
    2043           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTHLDASH;
    2044           0 :             break;
    2045             :         case UNDERLINE_BOLDDASHDOT:
    2046           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHD;
    2047           0 :             break;
    2048             :         case UNDERLINE_BOLDDASHDOTDOT:
    2049           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHDD;
    2050           0 :             break;
    2051             :         case UNDERLINE_BOLDWAVE:
    2052           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULHWAVE;
    2053           0 :             break;
    2054             :         case UNDERLINE_DOUBLEWAVE:
    2055           0 :             pStr = OOO_STRING_SVTOOLS_RTF_ULULDBWAVE;
    2056           0 :             break;
    2057             :         default:
    2058           0 :             break;
    2059             :     }
    2060             : 
    2061           0 :     if( pStr )
    2062             :     {
    2063           0 :         m_aStyles.append(pStr);
    2064             :         // NEEDSWORK looks like here rUnderline.GetColor() is always black,
    2065             :         // even if the color in the odt is for example green...
    2066           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ULC);
    2067           0 :         m_aStyles.append( (sal_Int32)m_rExport.GetColor(rUnderline.GetColor()) );
    2068             :     }
    2069           0 : }
    2070             : 
    2071           0 : void RtfAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
    2072             : {
    2073             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2074             : 
    2075           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
    2076           0 :     if ( rWeight.GetWeight() != WEIGHT_BOLD )
    2077           0 :         m_aStyles.append((sal_Int32)0);
    2078           0 : }
    2079             : 
    2080          56 : void RtfAttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern)
    2081             : {
    2082             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2083             : 
    2084          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KERNING);
    2085          56 :     m_aStyles.append((sal_Int32) (rAutoKern.GetValue() ? 1 : 0));
    2086          56 : }
    2087             : 
    2088           0 : void RtfAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
    2089             : {
    2090             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2091             : 
    2092           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ANIMTEXT);
    2093           0 :     m_aStyles.append((sal_Int32) (rBlink.GetValue() ? 2 : 0));
    2094           0 : }
    2095             : 
    2096           0 : void RtfAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
    2097             : {
    2098             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2099             : 
    2100           0 :     if( !rBrush.GetColor().GetTransparency() )
    2101             :     {
    2102           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
    2103           0 :         m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
    2104             :     }
    2105           0 : }
    2106             : 
    2107         256 : void RtfAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
    2108             : {
    2109             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2110             : 
    2111         256 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
    2112         256 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
    2113         256 :     m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
    2114         256 : }
    2115             : 
    2116           0 : void RtfAttributeOutput::CharFontSizeCJK( const SvxFontHeightItem& rFontSize )
    2117             : {
    2118             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2119             : 
    2120           0 :     CharFontSize( rFontSize );
    2121           0 : }
    2122             : 
    2123          56 : void RtfAttributeOutput::CharLanguageCJK( const SvxLanguageItem& rLanguageItem )
    2124             : {
    2125             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2126             : 
    2127          56 :     CharLanguage( rLanguageItem );
    2128          56 : }
    2129             : 
    2130           0 : void RtfAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
    2131             : {
    2132             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2133             : 
    2134           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
    2135           0 :     if ( rPosture.GetPosture() == ITALIC_NONE )
    2136           0 :         m_aStyles.append((sal_Int32)0);
    2137           0 : }
    2138             : 
    2139           0 : void RtfAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight )
    2140             : {
    2141             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2142             : 
    2143           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
    2144           0 :     if ( rWeight.GetWeight() != WEIGHT_BOLD )
    2145           0 :         m_aStyles.append((sal_Int32)0);
    2146           0 : }
    2147             : 
    2148         274 : void RtfAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
    2149             : {
    2150             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2151             : 
    2152         274 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
    2153         274 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
    2154         274 :     m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
    2155         274 : }
    2156             : 
    2157         170 : void RtfAttributeOutput::CharFontSizeCTL( const SvxFontHeightItem& rFontSize )
    2158             : {
    2159             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2160             : 
    2161         170 :     CharFontSize( rFontSize );
    2162         170 : }
    2163             : 
    2164          60 : void RtfAttributeOutput::CharLanguageCTL( const SvxLanguageItem& rLanguageItem )
    2165             : {
    2166             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2167             : 
    2168          60 :     CharLanguage( rLanguageItem );
    2169          60 : }
    2170             : 
    2171          56 : void RtfAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
    2172             : {
    2173             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2174             : 
    2175          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AI);
    2176          56 :     if ( rPosture.GetPosture() == ITALIC_NONE )
    2177           0 :         m_aStyles.append((sal_Int32)0);
    2178          56 : }
    2179             : 
    2180           0 : void RtfAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
    2181             : {
    2182             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2183             : 
    2184           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AB);
    2185           0 :     if ( rWeight.GetWeight() != WEIGHT_BOLD )
    2186           0 :         m_aStyles.append((sal_Int32)0);
    2187           0 : }
    2188             : 
    2189           0 : void RtfAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
    2190             : {
    2191             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2192             : 
    2193           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HORZVERT);
    2194           0 :     m_aStyles.append((sal_Int32)(rRotate.IsFitToLine() ? 1 : 0));
    2195           0 : }
    2196             : 
    2197           0 : void RtfAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
    2198             : {
    2199             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2200             : 
    2201             :     const sal_Char* pStr;
    2202           0 :     switch( rEmphasisMark.GetEmphasisMark())
    2203             :     {
    2204           0 :         case EMPHASISMARK_NONE:         pStr = OOO_STRING_SVTOOLS_RTF_ACCNONE;  break;
    2205           0 :         case EMPHASISMARK_SIDE_DOTS:    pStr = OOO_STRING_SVTOOLS_RTF_ACCCOMMA; break;
    2206           0 :         default:                        pStr = OOO_STRING_SVTOOLS_RTF_ACCDOT;   break;
    2207             :     }
    2208           0 :     m_aStyles.append(pStr);
    2209           0 : }
    2210             : 
    2211           0 : void RtfAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
    2212             : {
    2213             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2214             : 
    2215           0 :     if( rTwoLines.GetValue() )
    2216             :     {
    2217           0 :         sal_Unicode cStart = rTwoLines.GetStartBracket();
    2218           0 :         sal_Unicode cEnd =   rTwoLines.GetEndBracket();
    2219             : 
    2220             :         sal_uInt16 nType;
    2221           0 :         if( !cStart && !cEnd )
    2222           0 :             nType = 0;
    2223           0 :         else if( '{' == cStart || '}' == cEnd )
    2224           0 :             nType = 4;
    2225           0 :         else if( '<' == cStart || '>' == cEnd )
    2226           0 :             nType = 3;
    2227           0 :         else if( '[' == cStart || ']' == cEnd )
    2228           0 :             nType = 2;
    2229             :         else                            // all other kind of brackets
    2230           0 :             nType = 1;
    2231             : 
    2232           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
    2233           0 :         m_aStyles.append((sal_Int32)nType);
    2234             :     }
    2235           0 : }
    2236             : 
    2237           0 : void RtfAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
    2238             : {
    2239             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2240             : 
    2241           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHARSCALEX);
    2242           0 :     m_aStyles.append((sal_Int32)rScaleWidth.GetValue());
    2243           0 : }
    2244             : 
    2245           0 : void RtfAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
    2246             : {
    2247             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2248             : 
    2249             :     const sal_Char* pStr;
    2250           0 :     switch (rRelief.GetValue())
    2251             :     {
    2252             :         case RELIEF_EMBOSSED:
    2253           0 :             pStr = OOO_STRING_SVTOOLS_RTF_EMBO;
    2254           0 :             break;
    2255             :         case RELIEF_ENGRAVED:
    2256           0 :             pStr = OOO_STRING_SVTOOLS_RTF_IMPR;
    2257           0 :             break;
    2258             :         default:
    2259           0 :             pStr = 0;
    2260           0 :             break;
    2261             :     }
    2262             : 
    2263           0 :     if (pStr)
    2264           0 :         m_aStyles.append(pStr);
    2265           0 : }
    2266             : 
    2267           0 : void RtfAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
    2268             : {
    2269             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2270             : 
    2271           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_V);
    2272           0 :     if ( !rHidden.GetValue() )
    2273           0 :         m_aStyles.append((sal_Int32)0);
    2274           0 : }
    2275             : 
    2276           0 : void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
    2277             : {
    2278             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2279             : 
    2280           0 :     if( rURL.GetValue().Len() )
    2281             :     {
    2282             :         const SwCharFmt* pFmt;
    2283           0 :         const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
    2284             : 
    2285           0 :         m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
    2286           0 :         m_bHadFieldResult = true;
    2287           0 :         if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
    2288             :         {
    2289           0 :             sal_uInt16 nStyle = m_rExport.GetId( *pFmt );
    2290           0 :             OString* pString = m_rExport.GetStyle(nStyle);
    2291           0 :             if (pString)
    2292           0 :                 m_aStyles.append(*pString);
    2293             :         }
    2294             :     }
    2295           0 : }
    2296             : 
    2297           0 : void RtfAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
    2298             : {
    2299             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2300             : 
    2301           0 :     sal_uInt16 nStyle = m_rExport.GetId( *rCharFmt.GetCharFmt() );
    2302           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CS);
    2303           0 :     m_aStyles.append((sal_Int32)nStyle);
    2304           0 :     OString* pString = m_rExport.GetStyle(nStyle);
    2305           0 :     if (pString)
    2306           0 :         m_aStyles.append(*pString);
    2307           0 : }
    2308             : 
    2309           4 : void RtfAttributeOutput::WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote)
    2310             : {
    2311           4 :     if (!rFootnote.GetNumStr().Len())
    2312           4 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_CHFTN);
    2313             :     else
    2314           0 :         m_aRun->append(msfilter::rtfutil::OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
    2315           4 : }
    2316             : 
    2317           2 : void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
    2318             : {
    2319             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << " start");
    2320             : 
    2321           2 :     m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
    2322           2 :     WriteTextFootnoteNumStr(rFootnote);
    2323           2 :     m_aRun->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
    2324           2 :     if( rFootnote.IsEndNote() )
    2325           0 :         m_aRun->append(OOO_STRING_SVTOOLS_RTF_FTNALT);
    2326           2 :     m_aRun->append(' ');
    2327           2 :     WriteTextFootnoteNumStr(rFootnote);
    2328             : 
    2329             :     /*
    2330             :      * The footnote contains a whole paragraph, so we have to:
    2331             :      * 1) Reset, then later restore the contents of our run buffer and run state.
    2332             :      * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
    2333             :      */
    2334           2 :     const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
    2335           2 :     RtfStringBuffer aRun = m_aRun;
    2336           2 :     m_aRun.clear();
    2337           2 :     bool bInRunOrig = m_bInRun;
    2338           2 :     m_bInRun = false;
    2339           2 :     m_bBufferSectionHeaders = true;
    2340           2 :     m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
    2341           2 :             pIndex->GetNode().EndOfSectionIndex(),
    2342           6 :             !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
    2343           2 :     m_bBufferSectionHeaders = false;
    2344           2 :     m_bInRun = bInRunOrig;
    2345           2 :     m_aRun = aRun;
    2346           2 :     m_aRun->append(m_aSectionHeaders.makeStringAndClear());
    2347             : 
    2348           2 :     m_aRun->append("}");
    2349           2 :     m_aRun->append("}");
    2350             : 
    2351           2 :     SAL_INFO("sw.rtf", OSL_THIS_FUNC << " end");
    2352           2 : }
    2353             : 
    2354           0 : void RtfAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
    2355             : {
    2356             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2357             : 
    2358           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SL);
    2359           0 :     m_aStyles.append((sal_Int32)nSpace);
    2360           0 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SLMULT);
    2361           0 :     m_aStyles.append((sal_Int32)nMulti);
    2362             : 
    2363           0 : }
    2364             : 
    2365           0 : void RtfAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
    2366             : {
    2367             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2368             : 
    2369           0 :     switch ( rAdjust.GetAdjust() )
    2370             :     {
    2371             :         case SVX_ADJUST_LEFT:
    2372           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QL);
    2373           0 :             break;
    2374             :         case SVX_ADJUST_RIGHT:
    2375           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QR);
    2376           0 :             break;
    2377             :         case SVX_ADJUST_BLOCKLINE:
    2378             :         case SVX_ADJUST_BLOCK:
    2379           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
    2380           0 :             break;
    2381             :         case SVX_ADJUST_CENTER:
    2382           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QC);
    2383           0 :             break;
    2384             :         default:
    2385           0 :             break;
    2386             :     }
    2387           0 : }
    2388             : 
    2389           0 : void RtfAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
    2390             : {
    2391             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2392             : 
    2393           0 :     if( !rSplit.GetValue() )
    2394           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEP);
    2395           0 : }
    2396             : 
    2397          56 : void RtfAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
    2398             : {
    2399             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2400             : 
    2401          56 :     if (rWidows.GetValue())
    2402           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_WIDCTLPAR);
    2403             :     else
    2404          56 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOWIDCTLPAR);
    2405          56 : }
    2406             : 
    2407          56 : void RtfAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
    2408             : {
    2409             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2410             : 
    2411          56 :     long nOffset = ((SvxLRSpaceItem&)m_rExport.GetItem( RES_LR_SPACE )).GetTxtLeft();
    2412         112 :     for( sal_uInt16 n = 0; n < rTabStop.Count(); n++ )
    2413             :     {
    2414          56 :         const SvxTabStop & rTS = rTabStop[ n ];
    2415          56 :         if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() )
    2416             :         {
    2417           0 :             const char* pFill = 0;
    2418           0 :             switch( rTS.GetFill() )
    2419             :             {
    2420             :                 case cDfltFillChar:
    2421           0 :                     break;
    2422             : 
    2423           0 :                 case '.':    pFill = OOO_STRING_SVTOOLS_RTF_TLDOT;    break;
    2424           0 :                 case '_':    pFill = OOO_STRING_SVTOOLS_RTF_TLUL;    break;
    2425           0 :                 case '-':    pFill = OOO_STRING_SVTOOLS_RTF_TLTH;    break;
    2426           0 :                 case '=':    pFill = OOO_STRING_SVTOOLS_RTF_TLEQ;    break;
    2427             :                 default:
    2428           0 :                         break;
    2429             :             }
    2430           0 :             if( pFill )
    2431           0 :                 m_aStyles.append(pFill);
    2432             : 
    2433           0 :             const sal_Char* pAdjStr = 0;
    2434           0 :             switch (rTS.GetAdjustment())
    2435             :             {
    2436             :                 case SVX_TAB_ADJUST_RIGHT:
    2437           0 :                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQR;
    2438           0 :                     break;
    2439             :                 case SVX_TAB_ADJUST_DECIMAL:
    2440           0 :                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQDEC;
    2441           0 :                     break;
    2442             :                 case SVX_TAB_ADJUST_CENTER:
    2443           0 :                     pAdjStr = OOO_STRING_SVTOOLS_RTF_TQC;
    2444           0 :                     break;
    2445             :                 default:
    2446           0 :                     break;
    2447             :             }
    2448           0 :             if (pAdjStr)
    2449           0 :                 m_aStyles.append(pAdjStr);
    2450           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TX);
    2451           0 :             m_aStyles.append((sal_Int32)(rTS.GetTabPos() + nOffset));
    2452             :         }
    2453             :         else
    2454             :         {
    2455          56 :             m_aTabStop.append( OOO_STRING_SVTOOLS_RTF_DEFTAB );
    2456          56 :             m_aTabStop.append( (sal_Int32)rTabStop[0].GetTabPos() );
    2457             :         }
    2458             :     }
    2459          56 : }
    2460             : 
    2461          56 : void RtfAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
    2462             : {
    2463             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2464             : 
    2465          56 :     sal_Int32 nFlags = rHyphenZone.IsHyphen() ? 1 : 0;
    2466          56 :     if( rHyphenZone.IsPageEnd() )
    2467          56 :         nFlags += 2;
    2468          56 :     m_aStyles.append('{');
    2469          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
    2470          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHEN);
    2471          56 :     m_aStyles.append((sal_Int32)nFlags);
    2472          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHLEAD);
    2473          56 :     m_aStyles.append((sal_Int32)rHyphenZone.GetMinLead());
    2474          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHTRAIL);
    2475          56 :     m_aStyles.append((sal_Int32)rHyphenZone.GetMinTrail());
    2476          56 :     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHMAX);
    2477          56 :     m_aStyles.append((sal_Int32)rHyphenZone.GetMaxHyphens());
    2478          56 :     m_aStyles.append('}');
    2479          56 : }
    2480             : 
    2481           0 : void RtfAttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId )
    2482             : {
    2483             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2484             : 
    2485           0 :     if ( USHRT_MAX == nNumId || 0 == nNumId || 0 == pTxtNd)
    2486           0 :         return;
    2487             : 
    2488           0 :     const SwNumRule* pRule = pTxtNd->GetNumRule();
    2489             : 
    2490           0 :     if( pRule && pTxtNd->IsInList() )
    2491             :     {
    2492             :         OSL_ENSURE( pTxtNd->GetActualListLevel() >= 0 && pTxtNd->GetActualListLevel() < MAXLEVEL,
    2493             :                 "<SwRTFWriter::OutListNum(..)> - text node does not have valid list level. Serious defect -> please inform OD" );
    2494             : 
    2495           0 :         const bool bExportNumRule = USHRT_MAX != nNumId;
    2496           0 :         const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
    2497           0 :         if( !pFmt )
    2498           0 :             pFmt = &pRule->Get( nLvl );
    2499             : 
    2500           0 :         const SfxItemSet& rNdSet = pTxtNd->GetSwAttrSet();
    2501             : 
    2502           0 :         if ( bExportNumRule ) {
    2503           0 :             m_aStyles.append('{');
    2504           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LISTTEXT);
    2505           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PARD);
    2506           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
    2507           0 :             m_aStyles.append(' ');
    2508             :         }
    2509             : 
    2510           0 :         SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
    2511           0 :         aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetIndentAt() );
    2512           0 :         aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
    2513             : 
    2514           0 :         sal_uInt16 nStyle = m_rExport.GetId( *pFmt->GetCharFmt() );
    2515           0 :         OString* pString = m_rExport.GetStyle(nStyle);
    2516           0 :         if (pString)
    2517           0 :             m_aStyles.append(*pString);
    2518             : 
    2519             :         {
    2520           0 :             String sTxt;
    2521           0 :             if( SVX_NUM_CHAR_SPECIAL == pFmt->GetNumberingType() || SVX_NUM_BITMAP == pFmt->GetNumberingType() )
    2522           0 :                 sTxt = pFmt->GetBulletChar();
    2523             :             else
    2524           0 :                 sTxt = pTxtNd->GetNumString();
    2525             : 
    2526           0 :             if (sTxt.Len())
    2527             :             {
    2528           0 :                 m_aStyles.append(' ');
    2529           0 :                 m_aStyles.append(msfilter::rtfutil::OutString(sTxt, m_rExport.eDefaultEncoding));
    2530             :             }
    2531             : 
    2532           0 :             if( bExportNumRule )
    2533             :             {
    2534           0 :                 if( OUTLINE_RULE != pRule->GetRuleType() )
    2535             :                 {
    2536           0 :                     if (sTxt.Len())
    2537           0 :                         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
    2538           0 :                     m_aStyles.append('}');
    2539           0 :                     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
    2540           0 :                     if( nLvl > 8 )            // RTF knows only 9 levels
    2541             :                     {
    2542           0 :                         m_aStyles.append((sal_Int32)8);
    2543           0 :                         m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SOUTLVL);
    2544           0 :                         m_aStyles.append((sal_Int32)nLvl);
    2545           0 :                         m_aStyles.append('}');
    2546             :                     }
    2547             :                     else
    2548           0 :                         m_aStyles.append((sal_Int32)nLvl);
    2549             :                 }
    2550             :                 else
    2551           0 :                     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB "}");
    2552           0 :                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LS);
    2553           0 :                 m_aStyles.append((sal_Int32)m_rExport.GetId(*pRule)+1);
    2554           0 :                 m_aStyles.append(' ');
    2555             :             }
    2556           0 :             else if( sTxt.Len() )
    2557           0 :                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
    2558             :         }
    2559           0 :         FormatLRSpace(aLR);
    2560             :     }
    2561             : }
    2562             : 
    2563          24 : void RtfAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
    2564             : {
    2565             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2566             : 
    2567          24 :     if (!rScriptSpace.GetValue( ))
    2568          24 :         return;
    2569          24 :     switch ( rScriptSpace.Which( ) )
    2570             :     {
    2571             :         case RES_PARATR_SCRIPTSPACE:
    2572           8 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ASPALPHA);
    2573           8 :             break;
    2574             : 
    2575             :         default:
    2576          16 :             break;
    2577             :     }
    2578             : }
    2579             : 
    2580           0 : void RtfAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
    2581             : {
    2582             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2583             : 
    2584             :     const char* pStr;
    2585           0 :     switch ( rAlign.GetValue() )
    2586             :     {
    2587           0 :         case SvxParaVertAlignItem::TOP:         pStr = OOO_STRING_SVTOOLS_RTF_FAHANG;       break;
    2588           0 :         case SvxParaVertAlignItem::BOTTOM:      pStr = OOO_STRING_SVTOOLS_RTF_FAVAR;        break;
    2589           0 :         case SvxParaVertAlignItem::CENTER:      pStr = OOO_STRING_SVTOOLS_RTF_FACENTER;     break;
    2590           0 :         case SvxParaVertAlignItem::BASELINE:    pStr = OOO_STRING_SVTOOLS_RTF_FAROMAN;      break;
    2591             : 
    2592           0 :         default:                                pStr = OOO_STRING_SVTOOLS_RTF_FAAUTO;       break;
    2593             :     }
    2594           0 :     m_aStyles.append(pStr);
    2595           0 : }
    2596             : 
    2597           0 : void RtfAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& /*rGrid*/ )
    2598             : {
    2599             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2600           0 : }
    2601             : 
    2602         136 : void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
    2603             : {
    2604             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2605             : 
    2606         136 :     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
    2607             :     {
    2608           6 :         if( rSize.GetWidth() )
    2609             :         {
    2610           6 :             m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSW);
    2611           6 :             m_aRunText->append((sal_Int32)rSize.GetWidth());
    2612             :         }
    2613             : 
    2614           6 :         if( rSize.GetHeight() )
    2615             :         {
    2616           6 :             long nH = rSize.GetHeight();
    2617           6 :             if( ATT_FIX_SIZE == rSize.GetHeightSizeType() )
    2618           0 :                 nH = -nH;
    2619           6 :             m_aRunText->append(OOO_STRING_SVTOOLS_RTF_ABSH);
    2620           6 :             m_aRunText->append((sal_Int32)nH);
    2621           6 :         }
    2622             :     }
    2623         130 :     else if (m_rExport.bOutPageDescs)
    2624             :     {
    2625         124 :         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGWSXN);
    2626         124 :         m_aSectionBreaks.append((sal_Int32)rSize.GetWidth());
    2627         124 :         m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGHSXN);
    2628         124 :         m_aSectionBreaks.append((sal_Int32)rSize.GetHeight());
    2629         124 :         if (!m_bBufferSectionBreaks)
    2630         122 :             m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear().getStr();
    2631             :     }
    2632         136 : }
    2633             : 
    2634           0 : void RtfAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
    2635             : {
    2636             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2637           0 : }
    2638             : 
    2639         138 : void RtfAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
    2640             : {
    2641             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2642             : 
    2643         138 :     if ( !m_rExport.bOutFlyFrmAttrs )
    2644             :     {
    2645         126 :         if( m_rExport.bOutPageDescs )
    2646             :         {
    2647         124 :             if( rLRSpace.GetLeft() )
    2648             :             {
    2649         124 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN);
    2650         124 :                 m_aSectionBreaks.append((sal_Int32)rLRSpace.GetLeft());
    2651             :             }
    2652         124 :             if( rLRSpace.GetRight() )
    2653             :             {
    2654         124 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN);
    2655         124 :                 m_aSectionBreaks.append((sal_Int32)rLRSpace.GetRight());
    2656             :             }
    2657         124 :             if (!m_bBufferSectionBreaks)
    2658         122 :                 m_rExport.Strm() <<
    2659         244 :                     m_aSectionBreaks.makeStringAndClear().getStr();
    2660             :         }
    2661             :         else
    2662             :         {
    2663           2 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI);
    2664           2 :             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
    2665           2 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI);
    2666           2 :             m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
    2667           2 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN);
    2668           2 :             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
    2669           2 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN);
    2670           2 :             m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
    2671           2 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI);
    2672           2 :             m_aStyles.append( (sal_Int32) rLRSpace.GetTxtFirstLineOfst() );
    2673             :         }
    2674             :     }
    2675          12 :     else if (rLRSpace.GetLeft() == rLRSpace.GetRight() && m_rExport.bRTFFlySyntax)
    2676             :     {
    2677           6 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTX;
    2678           6 :         m_rExport.OutLong( rLRSpace.GetLeft() );
    2679             :     }
    2680         138 : }
    2681             : 
    2682         374 : void RtfAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
    2683             : {
    2684             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2685             : 
    2686         374 :     if ( !m_rExport.bOutFlyFrmAttrs )
    2687             :     {
    2688         362 :         if( m_rExport.bOutPageDescs )
    2689             :         {
    2690             :             OSL_ENSURE( m_rExport.GetCurItemSet(), "Impossible" );
    2691         124 :             if ( !m_rExport.GetCurItemSet() )
    2692         374 :                 return;
    2693             : 
    2694         124 :             HdFtDistanceGlue aDistances( *m_rExport.GetCurItemSet() );
    2695             : 
    2696         124 :             if( aDistances.dyaTop )
    2697             :             {
    2698         124 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGTSXN);
    2699         124 :                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaTop);
    2700             :             }
    2701         124 :             if ( aDistances.HasHeader() )
    2702             :             {
    2703           0 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_HEADERY);
    2704           0 :                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrTop);
    2705             :             }
    2706             : 
    2707         124 :             if( aDistances.dyaBottom )
    2708             :             {
    2709         124 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGBSXN);
    2710         124 :                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaBottom);
    2711             :             }
    2712         124 :             if( aDistances.HasFooter() )
    2713             :             {
    2714           0 :                 m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_FOOTERY);
    2715           0 :                 m_aSectionBreaks.append((sal_Int32)aDistances.dyaHdrBottom);
    2716             :             }
    2717         124 :             if (!m_bBufferSectionBreaks)
    2718         122 :                 m_rExport.Strm() <<
    2719         244 :                     m_aSectionBreaks.makeStringAndClear().getStr();
    2720             :         }
    2721             :         else
    2722             :         {
    2723         238 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SB);
    2724         238 :             m_aStyles.append( (sal_Int32) rULSpace.GetUpper() );
    2725         238 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SA);
    2726         238 :             m_aStyles.append( (sal_Int32) rULSpace.GetLower() );
    2727         238 :             if (rULSpace.GetContext())
    2728           0 :                 m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CONTEXTUALSPACE);
    2729             :         }
    2730             :     }
    2731          12 :     else if (rULSpace.GetUpper() == rULSpace.GetLower() && m_rExport.bRTFFlySyntax)
    2732             :     {
    2733           6 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_DFRMTXTY;
    2734           6 :         m_rExport.OutLong( rULSpace.GetLower() );
    2735             :     }
    2736             : }
    2737             : 
    2738          12 : void RtfAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
    2739             : {
    2740             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2741             : 
    2742          12 :     if ( m_rExport.bOutFlyFrmAttrs && !m_rExport.bRTFFlySyntax )
    2743             :     {
    2744           6 :         SwSurround eSurround = rSurround.GetSurround();
    2745           6 :         sal_Bool bGold = SURROUND_IDEAL == eSurround;
    2746           6 :         if( bGold )
    2747           0 :             eSurround = SURROUND_PARALLEL;
    2748           6 :         RTFSurround aMC( bGold, static_cast< sal_uInt8 >(eSurround) );
    2749           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
    2750           6 :         m_aRunText->append( (sal_Int32) aMC.GetValue() );
    2751             :     }
    2752          12 : }
    2753             : 
    2754          12 : void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
    2755             : {
    2756             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2757             : 
    2758          12 :     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
    2759             :     {
    2760           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PVPARA);
    2761             : 
    2762          12 :         switch (rFlyVert.GetVertOrient())
    2763             :         {
    2764             :             case text::VertOrientation::TOP:
    2765             :             case text::VertOrientation::LINE_TOP:
    2766           4 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYT);
    2767           4 :                 break;
    2768             :             case text::VertOrientation::BOTTOM:
    2769             :             case text::VertOrientation::LINE_BOTTOM:
    2770           0 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYB);
    2771           0 :                 break;
    2772             :             case text::VertOrientation::CENTER:
    2773             :             case text::VertOrientation::LINE_CENTER:
    2774           0 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSYC);
    2775           0 :                 break;
    2776             :             case text::VertOrientation::NONE:
    2777           2 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSY);
    2778           2 :                 m_aRunText->append((sal_Int32)rFlyVert.GetPos());
    2779           2 :                 break;
    2780             :             default:
    2781           0 :                 break;
    2782             :         }
    2783             :     }
    2784           6 :     else if ( !m_rExport.bRTFFlySyntax )
    2785             :     {
    2786           6 :         RTFVertOrient aVO( static_cast< sal_uInt16 >(rFlyVert.GetVertOrient()), static_cast< sal_uInt16 >(rFlyVert.GetRelationOrient()) );
    2787           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
    2788           6 :         m_aRunText->append((sal_Int32)aVO.GetValue());
    2789             :     }
    2790          12 : }
    2791             : 
    2792          12 : void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
    2793             : {
    2794             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2795             : 
    2796          12 :     if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
    2797             :     {
    2798           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_PHCOL);
    2799             : 
    2800           6 :         const char* pS = 0;
    2801           6 :         switch(rFlyHori.GetHoriOrient())
    2802             :         {
    2803             :             case text::HoriOrientation::RIGHT:
    2804           0 :                 pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXO : OOO_STRING_SVTOOLS_RTF_POSXR;
    2805           0 :                 break;
    2806             :             case text::HoriOrientation::LEFT:
    2807           0 :                 pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXI : OOO_STRING_SVTOOLS_RTF_POSXL;
    2808           0 :                 break;
    2809             :             case text::HoriOrientation::CENTER:
    2810           4 :                 pS = OOO_STRING_SVTOOLS_RTF_POSXC;
    2811           4 :                 break;
    2812             :             case text::HoriOrientation::NONE:
    2813           2 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_POSX);
    2814           2 :                 m_aRunText->append((sal_Int32)rFlyHori.GetPos());
    2815           2 :                 break;
    2816             :             default:
    2817           0 :                 break;
    2818             :         }
    2819           6 :         if (pS)
    2820           4 :             m_aRunText->append(pS);
    2821           6 :     } else if ( !m_rExport.bRTFFlySyntax )
    2822             :     {
    2823           6 :         RTFHoriOrient aHO( static_cast< sal_uInt16 >(rFlyHori.GetHoriOrient()),
    2824          12 :                 static_cast< sal_uInt16 >(rFlyHori.GetRelationOrient()) );
    2825           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
    2826           6 :         m_aRunText->append((sal_Int32)aHO.GetValue());
    2827             :     }
    2828          12 : }
    2829             : 
    2830          12 : void RtfAttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
    2831             : {
    2832             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2833             : 
    2834          12 :     if ( !m_rExport.bRTFFlySyntax )
    2835             :     {
    2836           6 :         sal_uInt16 nId = static_cast< sal_uInt16 >(rAnchor.GetAnchorId());
    2837           6 :         m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
    2838           6 :         m_aRunText->append((sal_Int32)nId);
    2839           6 :         switch( nId )
    2840             :         {
    2841             :             case FLY_AT_PAGE:
    2842           0 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
    2843           0 :                 m_aRunText->append((sal_Int32)rAnchor.GetPageNum());
    2844           0 :                 break;
    2845             :             case FLY_AT_PARA:
    2846             :             case FLY_AS_CHAR:
    2847           4 :                 m_aRunText->append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
    2848           4 :                 break;
    2849             :         }
    2850             :     }
    2851          12 : }
    2852             : 
    2853           0 : void RtfAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
    2854             : {
    2855             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2856             : 
    2857           0 :     if( !rBrush.GetColor().GetTransparency() )
    2858             :     {
    2859           0 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CBPAT);
    2860           0 :         m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
    2861             :     }
    2862           0 : }
    2863             : 
    2864          12 : void RtfAttributeOutput::FormatBox( const SvxBoxItem& rBox )
    2865             : {
    2866             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2867             : 
    2868             :     static sal_uInt16 aBorders[] = {
    2869             :         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
    2870             :     static const sal_Char* aBorderNames[] = {
    2871             :         OOO_STRING_SVTOOLS_RTF_BRDRT, OOO_STRING_SVTOOLS_RTF_BRDRL, OOO_STRING_SVTOOLS_RTF_BRDRB, OOO_STRING_SVTOOLS_RTF_BRDRR };
    2872             : 
    2873          12 :     sal_uInt16 nDist = rBox.GetDistance();
    2874             : 
    2875          12 :     if ( m_rExport.bRTFFlySyntax )
    2876          18 :         return;
    2877             : 
    2878          60 :     if( rBox.GetTop() && rBox.GetBottom() &&
    2879          12 :             rBox.GetLeft() && rBox.GetRight() &&
    2880           6 :             *rBox.GetTop() == *rBox.GetBottom() &&
    2881           6 :             *rBox.GetTop() == *rBox.GetLeft() &&
    2882           6 :             *rBox.GetTop() == *rBox.GetRight() &&
    2883           6 :             nDist == rBox.GetDistance( BOX_LINE_TOP ) &&
    2884           6 :             nDist == rBox.GetDistance( BOX_LINE_LEFT ) &&
    2885           6 :             nDist == rBox.GetDistance( BOX_LINE_BOTTOM ) &&
    2886           6 :             nDist == rBox.GetDistance( BOX_LINE_RIGHT ))
    2887           6 :         m_aSectionBreaks.append(OutBorderLine( m_rExport, rBox.GetTop(), OOO_STRING_SVTOOLS_RTF_BOX, nDist ));
    2888             :     else
    2889             :     {
    2890           0 :         const sal_uInt16* pBrd = aBorders;
    2891           0 :         const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
    2892           0 :         for(int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms)
    2893             :         {
    2894           0 :             if (const SvxBorderLine* pLn = rBox.GetLine(*pBrd))
    2895             :             {
    2896             :                 m_aSectionBreaks.append(OutBorderLine(m_rExport, pLn, *pBrdNms,
    2897           0 :                         rBox.GetDistance(*pBrd)));
    2898             :             }
    2899             :         }
    2900             :     }
    2901             : 
    2902           6 :     if (!m_bBufferSectionBreaks)
    2903           6 :         m_aStyles.append(m_aSectionBreaks.makeStringAndClear());
    2904             : }
    2905             : 
    2906           0 : void RtfAttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize )
    2907             : {
    2908             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2909             : 
    2910           0 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLS;
    2911           0 :     m_rExport.OutLong( nCols );
    2912             : 
    2913           0 :     if( bEven )
    2914             :     {
    2915           0 :         m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSX;
    2916           0 :         m_rExport.OutLong( rCol.GetGutterWidth( sal_True ) );
    2917             :     }
    2918             :     else
    2919             :     {
    2920           0 :         const SwColumns & rColumns = rCol.GetColumns( );
    2921           0 :         for( sal_uInt16 n = 0; n < nCols; )
    2922             :         {
    2923           0 :             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLNO;
    2924           0 :             m_rExport.OutLong( n+1 );
    2925             : 
    2926           0 :             m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLW;
    2927           0 :             m_rExport.OutLong( rCol.CalcPrtColWidth( n, nPageSize ) );
    2928             : 
    2929           0 :             if( ++n != nCols )
    2930             :             {
    2931           0 :                 m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSR;
    2932           0 :                 m_rExport.OutLong( rColumns[ n-1 ].GetRight() +
    2933           0 :                         rColumns[ n ].GetLeft() );
    2934             :             }
    2935             :         }
    2936             :     }
    2937           0 : }
    2938             : 
    2939          56 : void RtfAttributeOutput::FormatKeep( const SvxFmtKeepItem& rItem )
    2940             : {
    2941             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2942             : 
    2943          56 :     if( rItem.GetValue() )
    2944          56 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEPN);
    2945          56 : }
    2946             : 
    2947          98 : void RtfAttributeOutput::FormatTextGrid( const SwTextGridItem& /*rGrid*/ )
    2948             : {
    2949             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2950          98 : }
    2951             : 
    2952         114 : void RtfAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
    2953             : {
    2954             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2955             : 
    2956         114 :     if ( !rNumbering.IsCount( ) )
    2957         114 :         m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOLINE);
    2958         114 : }
    2959             : 
    2960         132 : void RtfAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
    2961             : {
    2962             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2963             : 
    2964         132 :     if (!m_rExport.bOutPageDescs)
    2965             :     {
    2966           8 :         if (rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP)
    2967           0 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RTLPAR);
    2968             :         else
    2969           8 :             m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LTRPAR);
    2970             :     }
    2971         132 : }
    2972             : 
    2973           0 : void RtfAttributeOutput::WriteExpand( const SwField* pFld )
    2974             : {
    2975             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2976           0 :     String sCmd;
    2977           0 :     m_rExport.OutputField(pFld, ww::eUNKNOWN, sCmd);
    2978           0 : }
    2979             : 
    2980           0 : void RtfAttributeOutput::RefField( const SwField& /*rFld*/, const String& /*rRef*/ )
    2981             : {
    2982             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2983           0 : }
    2984             : 
    2985           0 : void RtfAttributeOutput::HiddenField( const SwField& /*rFld*/ )
    2986             : {
    2987             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2988           0 : }
    2989             : 
    2990           0 : void RtfAttributeOutput::SetField( const SwField& /*rFld*/, ww::eField /*eType*/, const String& /*rCmd*/ )
    2991             : {
    2992             :     SAL_INFO("sw.rtf", "TODO: " << OSL_THIS_FUNC);
    2993           0 : }
    2994             : 
    2995           2 : void RtfAttributeOutput::PostitField( const SwField* pFld )
    2996             : {
    2997             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    2998             : 
    2999           2 :     const SwPostItField& rPFld = *(SwPostItField*)pFld;
    3000             : 
    3001           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
    3002           2 :     m_aRunText->append(OUStringToOString(OUString(rPFld.GetInitials()), m_rExport.eCurrentEncoding));
    3003           2 :     m_aRunText->append("}");
    3004           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
    3005           2 :     m_aRunText->append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
    3006           2 :     m_aRunText->append("}");
    3007           2 :     m_aRunText->append(OOO_STRING_SVTOOLS_RTF_CHATN);
    3008             : 
    3009           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
    3010           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNREF " ");
    3011           2 :     m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId++));
    3012           2 :     m_aRunText->append('}');
    3013           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
    3014           2 :     m_aRunText->append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDateTime()));
    3015           2 :     m_aRunText->append('}');
    3016           2 :     m_aRunText->append(OUStringToOString(OUString(rPFld.GetTxt()), m_rExport.eCurrentEncoding));
    3017           2 :     m_aRunText->append('}');
    3018           2 : }
    3019             : 
    3020           2 : void RtfAttributeOutput::WritePostitFieldStart()
    3021             : {
    3022           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFSTART " ");
    3023           2 :     m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
    3024           2 :     m_aRunText->append("}");
    3025           2 : }
    3026             : 
    3027           2 : void RtfAttributeOutput::WritePostitFieldEnd()
    3028             : {
    3029           2 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATRFEND " ");
    3030           2 :     m_aRunText->append(sal_Int32(m_nPostitFieldsMaxId));
    3031           2 :     m_aRunText->append("}");
    3032           2 : }
    3033             : 
    3034           0 : bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
    3035             : {
    3036             :     // this is handled in OutputFlyFrame_Impl()
    3037           0 :     return true;
    3038             : }
    3039             : 
    3040          56 : RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
    3041             :     : m_rExport( rExport ),
    3042             :     m_bStrikeDouble( false ),
    3043             :     m_pTableWrt( NULL ),
    3044             :     m_bTableCellOpen( false ),
    3045             :     m_nTableDepth( 0 ),
    3046             :     m_bTblAfterCell( false ),
    3047             :     m_nColBreakNeeded( false ),
    3048             :     m_bBufferSectionBreaks( false ),
    3049             :     m_bBufferSectionHeaders( false ),
    3050             :     m_bLastTable( true ),
    3051             :     m_bWroteCellInfo( false ),
    3052             :     m_bHadFieldResult( false ),
    3053             :     m_bTableRowEnded( false ),
    3054             :     m_aCells(),
    3055             :     m_bSingleEmptyRun(false),
    3056             :     m_bInRun(false),
    3057             :     m_nPostitFieldsMaxId(0),
    3058          56 :     m_pPrevPageDesc(0)
    3059             : {
    3060             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3061          56 : }
    3062             : 
    3063         112 : RtfAttributeOutput::~RtfAttributeOutput()
    3064             : {
    3065             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3066         112 : }
    3067             : 
    3068         240 : MSWordExportBase& RtfAttributeOutput::GetExport()
    3069             : {
    3070         240 :     return m_rExport;
    3071             : }
    3072             : 
    3073             : // These are used by wwFont::WriteRtf()
    3074             : 
    3075             : /// Start the font.
    3076         502 : void RtfAttributeOutput::StartFont( const String& rFamilyName ) const
    3077             : {
    3078             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3079             : 
    3080         502 :     m_rExport.Strm() << OUStringToOString( OUString( rFamilyName ), m_rExport.eCurrentEncoding ).getStr();
    3081         502 : }
    3082             : 
    3083             : /// End the font.
    3084         502 : void RtfAttributeOutput::EndFont() const
    3085             : {
    3086             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3087             : 
    3088         502 :     m_rExport.Strm() << ";}";
    3089         502 : }
    3090             : 
    3091             : /// Alternate name for the font.
    3092         160 : void RtfAttributeOutput::FontAlternateName( const String& rName ) const
    3093             : {
    3094             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3095             : 
    3096         160 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_FALT << ' ';
    3097         160 :     m_rExport.Strm() << OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ).getStr() << '}';
    3098         160 : }
    3099             : 
    3100             : /// Font charset.
    3101         502 : void RtfAttributeOutput::FontCharset( sal_uInt8 nCharSet ) const
    3102             : {
    3103             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3104             : 
    3105         502 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FCHARSET;
    3106         502 :     m_rExport.OutULong( nCharSet );
    3107         502 :     m_rExport.Strm() << ' ';
    3108         502 : }
    3109             : 
    3110             : /// Font family.
    3111         502 : void RtfAttributeOutput::FontFamilyType( FontFamily eFamily, const wwFont &rFont ) const
    3112             : {
    3113             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3114             : 
    3115         502 :     m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_F;
    3116             : 
    3117         502 :     const char* pStr = OOO_STRING_SVTOOLS_RTF_FNIL;
    3118         502 :     switch (eFamily)
    3119             :     {
    3120             :         case FAMILY_ROMAN:
    3121         226 :             pStr = OOO_STRING_SVTOOLS_RTF_FROMAN;
    3122         226 :             break;
    3123             :         case FAMILY_SWISS:
    3124         116 :             pStr = OOO_STRING_SVTOOLS_RTF_FSWISS;
    3125         116 :             break;
    3126             :         case FAMILY_MODERN:
    3127           0 :             pStr = OOO_STRING_SVTOOLS_RTF_FMODERN;
    3128           0 :             break;
    3129             :         case FAMILY_SCRIPT:
    3130           0 :             pStr = OOO_STRING_SVTOOLS_RTF_FSCRIPT;
    3131           0 :             break;
    3132             :         case FAMILY_DECORATIVE:
    3133           0 :             pStr = OOO_STRING_SVTOOLS_RTF_FDECOR;
    3134           0 :             break;
    3135             :         default:
    3136         160 :             break;
    3137             :     }
    3138         502 :     m_rExport.OutULong(m_rExport.maFontHelper.GetId(rFont)) << pStr;
    3139         502 : }
    3140             : 
    3141             : /// Font pitch.
    3142         502 : void RtfAttributeOutput::FontPitchType( FontPitch ePitch ) const
    3143             : {
    3144             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3145             : 
    3146         502 :     m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FPRQ;
    3147             : 
    3148         502 :     sal_uInt16 nVal = 0;
    3149         502 :     switch (ePitch)
    3150             :     {
    3151             :         case PITCH_FIXED:
    3152           0 :             nVal = 1;
    3153           0 :             break;
    3154             :         case PITCH_VARIABLE:
    3155         254 :             nVal = 2;
    3156         254 :             break;
    3157             :         default:
    3158         248 :             break;
    3159             :     }
    3160         502 :     m_rExport.OutULong(nVal);
    3161         502 : }
    3162             : 
    3163           0 : static bool IsEMF(const sal_uInt8 *pGraphicAry, unsigned long nSize)
    3164             : {
    3165           0 :     if (pGraphicAry && (nSize > 0x2c ))
    3166             :     {
    3167             :         // check the magic number
    3168           0 :         if (
    3169           0 :                 (pGraphicAry[0x28] == 0x20 ) && (pGraphicAry[0x29] == 0x45) &&
    3170           0 :                 (pGraphicAry[0x2a] == 0x4d ) && (pGraphicAry[0x2b] == 0x46)
    3171             :            )
    3172             :         {
    3173             :             //emf detected
    3174           0 :             return true;
    3175             :         }
    3176             :     }
    3177           0 :     return false;
    3178             : }
    3179             : 
    3180          58 : static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &rSize)
    3181             : {
    3182          58 :     if (rpGraphicAry && (rSize > 0x22))
    3183             :     {
    3184          58 :         if (
    3185          58 :              (rpGraphicAry[0] == 0xd7) && (rpGraphicAry[1] == 0xcd) &&
    3186           0 :              (rpGraphicAry[2] == 0xc6) && (rpGraphicAry[3] == 0x9a)
    3187             :            )
    3188             :         {   // we have to get rid of the metafileheader
    3189           0 :             rpGraphicAry += 22;
    3190           0 :             rSize -= 22;
    3191           0 :             return true;
    3192             :         }
    3193             :     }
    3194          58 :     return false;
    3195             : }
    3196             : 
    3197         116 : OString RtfAttributeOutput::WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, SvStream* pStream, sal_uInt32 nLimit)
    3198             : {
    3199         116 :     OStringBuffer aRet;
    3200             : 
    3201         116 :     sal_uInt32 nBreak = 0;
    3202      638100 :     for (sal_uInt32 i = 0; i < nSize; i++)
    3203             :     {
    3204      637984 :         OString sNo = OString::valueOf(sal_Int32(pData[i]), 16);
    3205      637984 :         if (sNo.getLength() < 2)
    3206             :         {
    3207      363726 :             if (pStream)
    3208           0 :                 (*pStream) << '0';
    3209             :             else
    3210      363726 :                 aRet.append('0');
    3211             :         }
    3212      637984 :         if (pStream)
    3213           0 :             (*pStream) << sNo.getStr();
    3214             :         else
    3215      637984 :             aRet.append(sNo);
    3216      637984 :         if (++nBreak == nLimit)
    3217             :         {
    3218        9900 :             if (pStream)
    3219           0 :                 (*pStream) << RtfExport::sNewLine;
    3220             :             else
    3221        9900 :                 aRet.append(RtfExport::sNewLine);
    3222        9900 :             nBreak = 0;
    3223             :         }
    3224      637984 :     }
    3225             : 
    3226         116 :     return aRet.makeStringAndClear();
    3227             : }
    3228             : 
    3229         232 : static void lcl_AppendSP( OStringBuffer& rBuffer,
    3230             :     const char cName[],
    3231             :     const ::rtl::OUString& rValue,
    3232             :     const RtfExport& rExport )
    3233             : {
    3234         232 :     rBuffer.append( "{" OOO_STRING_SVTOOLS_RTF_SP "{" ); // "{\sp{"
    3235         232 :     rBuffer.append( OOO_STRING_SVTOOLS_RTF_SN " " );//" \sn "
    3236         232 :     rBuffer.append( cName ); //"PropName"
    3237         232 :     rBuffer.append( "}{" OOO_STRING_SVTOOLS_RTF_SV " " );
    3238             : // "}{ \sv "
    3239         232 :     rBuffer.append( msfilter::rtfutil::OutString( rValue, rExport.eCurrentEncoding ) );
    3240         232 :     rBuffer.append( "}}" );
    3241         232 : }
    3242             : 
    3243         116 : static OString ExportPICT( const SwFlyFrmFmt* pFlyFrmFmt, const Size &rOrig, const Size &rRendered, const Size &rMapped,
    3244             :     const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry,
    3245             :     unsigned long nSize, const RtfExport& rExport, SvStream *pStream = 0 )
    3246             : {
    3247         116 :     OStringBuffer aRet;
    3248         116 :     bool bIsWMF = std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
    3249         116 :     if (pBLIPType && nSize && pGraphicAry)
    3250             :     {
    3251         116 :         aRet.append("{" OOO_STRING_SVTOOLS_RTF_PICT);
    3252             : 
    3253         116 :         if( pFlyFrmFmt )
    3254             :         {
    3255         116 :             String sDescription = pFlyFrmFmt->GetObjDescription();
    3256             :             //write picture properties - wzDescription at first
    3257             :             //looks like: "{\*\picprop{\sp{\sn PropertyName}{\sv PropertyValue}}}"
    3258         116 :             aRet.append( "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_PICPROP );//"{\*\picprop
    3259         116 :             lcl_AppendSP( aRet, "wzDescription", sDescription, rExport );
    3260         116 :             String sName = pFlyFrmFmt->GetObjTitle();
    3261         116 :             lcl_AppendSP( aRet, "wzName", sName, rExport );
    3262         116 :             aRet.append( "}" ); //"}"
    3263             :         }
    3264             : 
    3265         116 :         long nXCroppedSize = rOrig.Width()-(rCr.GetLeft() + rCr.GetRight());
    3266         116 :         long nYCroppedSize = rOrig.Height()-(rCr.GetTop() + rCr.GetBottom());
    3267             :         /* Graphic with a zero height or width, typically copied from webpages, caused crashes. */
    3268         116 :         if( !nXCroppedSize )
    3269           0 :             nXCroppedSize = 100;
    3270         116 :         if( !nYCroppedSize )
    3271           0 :             nYCroppedSize = 100;
    3272             : 
    3273             :         //Given the original size and taking cropping into account
    3274             :         //first, how much has the original been scaled to get the
    3275             :         //final rendered size
    3276         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEX);
    3277         116 :         aRet.append((sal_Int32)((100 * rRendered.Width()) / nXCroppedSize));
    3278         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEY);
    3279         116 :         aRet.append((sal_Int32)((100 * rRendered.Height()) / nYCroppedSize));
    3280             : 
    3281         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPL);
    3282         116 :         aRet.append((sal_Int32)rCr.GetLeft());
    3283         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPR);
    3284         116 :         aRet.append((sal_Int32)rCr.GetRight());
    3285         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPT);
    3286         116 :         aRet.append((sal_Int32)rCr.GetTop());
    3287         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPB);
    3288         116 :         aRet.append((sal_Int32)rCr.GetBottom());
    3289             : 
    3290         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICW);
    3291         116 :         aRet.append((sal_Int32)rMapped.Width());
    3292         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICH);
    3293         116 :         aRet.append((sal_Int32)rMapped.Height());
    3294             : 
    3295         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
    3296         116 :         aRet.append((sal_Int32)rOrig.Width());
    3297         116 :         aRet.append(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
    3298         116 :         aRet.append((sal_Int32)rOrig.Height());
    3299             : 
    3300         116 :         aRet.append(pBLIPType);
    3301         116 :         if (bIsWMF)
    3302             :         {
    3303          58 :             aRet.append((sal_Int32)8);
    3304          58 :             StripMetafileHeader(pGraphicAry, nSize);
    3305             :         }
    3306         116 :         aRet.append(RtfExport::sNewLine);
    3307         116 :         if (pStream)
    3308           0 :             (*pStream) << aRet.makeStringAndClear().getStr();
    3309         116 :         if (pStream)
    3310           0 :             RtfAttributeOutput::WriteHex(pGraphicAry, nSize, pStream);
    3311             :         else
    3312         116 :             aRet.append(RtfAttributeOutput::WriteHex(pGraphicAry, nSize));
    3313         116 :         aRet.append('}');
    3314         116 :         if (pStream)
    3315           0 :             (*pStream) << aRet.makeStringAndClear().getStr();
    3316             :     }
    3317         116 :     return aRet.makeStringAndClear();
    3318             : }
    3319             : 
    3320          58 : void RtfAttributeOutput::FlyFrameOLEReplacement(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
    3321             : {
    3322          58 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
    3323          58 :     Size aSize(sw::util::GetSwappedInSize(rOLENode));
    3324          58 :     Size aRendered(aSize);
    3325          58 :     aRendered.Width() = rSize.Width();
    3326          58 :     aRendered.Height() = rSize.Height();
    3327          58 :     Graphic* pGraphic = rOLENode.GetGraphic();
    3328          58 :     Size aMapped(pGraphic->GetPrefSize());
    3329          58 :     const SwCropGrf &rCr = (const SwCropGrf &)rOLENode.GetAttr(RES_GRFATR_CROPGRF);
    3330          58 :     const sal_Char* pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
    3331          58 :     const sal_uInt8* pGraphicAry = 0;
    3332          58 :     SvMemoryStream aStream;
    3333          58 :     if (GraphicConverter::Export(aStream, *pGraphic, CVT_PNG) != ERRCODE_NONE)
    3334             :         OSL_FAIL("failed to export the graphic");
    3335          58 :     aStream.Seek(STREAM_SEEK_TO_END);
    3336          58 :     sal_uInt32 nSize = aStream.Tell();
    3337          58 :     pGraphicAry = (sal_uInt8*)aStream.GetData();
    3338          58 :     m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
    3339          58 :     m_aRunText->append("}"); // shppict
    3340          58 :     m_aRunText->append("{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
    3341          58 :     pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
    3342          58 :     SvMemoryStream aWmfStream;
    3343          58 :     if (GraphicConverter::Export(aWmfStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
    3344             :         OSL_FAIL("failed to export the graphic");
    3345          58 :     aWmfStream.Seek(STREAM_SEEK_TO_END);
    3346          58 :     nSize = aWmfStream.Tell();
    3347          58 :     pGraphicAry = (sal_uInt8*)aStream.GetData();
    3348          58 :     m_aRunText->append(ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport ));
    3349          58 :     m_aRunText->append("}"); // nonshppict
    3350          58 : }
    3351             : 
    3352          58 : bool RtfAttributeOutput::FlyFrameOLEMath(const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize)
    3353             : {
    3354             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3355             : 
    3356          58 :     uno::Reference <embed::XEmbeddedObject> xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
    3357          58 :     sal_Int64 nAspect = rOLENode.GetAspect();
    3358          58 :     svt::EmbeddedObjectRef aObjRef(xObj, nAspect);
    3359          58 :     SvGlobalName aObjName(aObjRef->getClassID());
    3360             : 
    3361          58 :     if (!SotExchange::IsMath(aObjName))
    3362           0 :         return false;
    3363             : 
    3364          58 :     m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATH " ");
    3365          58 :     uno::Reference<util::XCloseable> xClosable(xObj->getComponent(), uno::UNO_QUERY);
    3366             : // gcc4.4 (and 4.3 and possibly older) have a problem with dynamic_cast directly to the target class,
    3367             : // so help it with an intermediate cast. I'm not sure what exactly the problem is, seems to be unrelated
    3368             : // to RTLD_GLOBAL, so most probably a gcc bug.
    3369          58 :     oox::FormulaExportBase* pBase = dynamic_cast<oox::FormulaExportBase*>(dynamic_cast<SfxBaseModel*>(xClosable.get()));
    3370             :     assert( pBase != NULL );
    3371          58 :     OStringBuffer aBuf;
    3372          58 :     pBase->writeFormulaRtf(aBuf, m_rExport.eCurrentEncoding);
    3373          58 :     m_aRunText->append(aBuf.makeStringAndClear());
    3374             :     // Replacement graphic.
    3375          58 :     m_aRunText->append("{" LO_STRING_SVTOOLS_RTF_MMATHPICT " ");
    3376          58 :     FlyFrameOLEReplacement(pFlyFrmFmt, rOLENode, rSize);
    3377          58 :     m_aRunText->append("}"); // mmathPict
    3378          58 :     m_aRunText->append("}"); // mmath
    3379             : 
    3380          58 :     return true;
    3381             : }
    3382             : 
    3383          58 : void RtfAttributeOutput::FlyFrameOLE( const SwFlyFrmFmt* pFlyFrmFmt, SwOLENode& rOLENode, const Size& rSize )
    3384             : {
    3385             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3386             : 
    3387          58 :     if (FlyFrameOLEMath(pFlyFrmFmt, rOLENode, rSize))
    3388         116 :         return;
    3389             : 
    3390           0 :     FlyFrameOLEReplacement(pFlyFrmFmt, rOLENode, rSize);
    3391             : }
    3392             : 
    3393           0 : void RtfAttributeOutput::FlyFrameGraphic( const SwFlyFrmFmt* pFlyFrmFmt, const SwGrfNode* pGrfNode)
    3394             : {
    3395             :     SAL_INFO("sw.rtf", OSL_THIS_FUNC);
    3396             : 
    3397           0 :     SvMemoryStream aStream;
    3398           0 :     const sal_uInt8* pGraphicAry = 0;
    3399           0 :     sal_uInt32 nSize = 0;
    3400             : 
    3401           0 :     Graphic aGraphic(pGrfNode->GetGrf());
    3402             : 
    3403             :     // If there is no graphic there is not much point in parsing it
    3404           0 :     if(aGraphic.GetType()==GRAPHIC_NONE)
    3405           0 :         return;
    3406             : 
    3407           0 :     GfxLink aGraphicLink;
    3408           0 :     const sal_Char* pBLIPType = 0;
    3409           0 :     if (aGraphic.IsLink())
    3410             :     {
    3411           0 :         aGraphicLink = aGraphic.GetLink();
    3412           0 :         nSize = aGraphicLink.GetDataSize();
    3413           0 :         pGraphicAry = aGraphicLink.GetData();
    3414           0 :         switch (aGraphicLink.GetType())
    3415             :         {
    3416             :             case GFX_LINK_TYPE_NATIVE_JPG:
    3417           0 :                 pBLIPType = OOO_STRING_SVTOOLS_RTF_JPEGBLIP;
    3418           0 :                 break;
    3419             :             case GFX_LINK_TYPE_NATIVE_PNG:
    3420           0 :                 pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
    3421           0 :                 break;
    3422             :             case GFX_LINK_TYPE_NATIVE_WMF:
    3423             :                 pBLIPType =
    3424           0 :                     IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
    3425           0 :                 break;
    3426             :             default:
    3427           0 :                 break;
    3428             :         }
    3429             :     }
    3430             : 
    3431           0 :     GraphicType eGraphicType = aGraphic.GetType();
    3432           0 :     if (!pGraphicAry)
    3433             :     {
    3434           0 :         if (ERRCODE_NONE == GraphicConverter::Export(aStream, aGraphic,
    3435           0 :                     (eGraphicType == GRAPHIC_BITMAP) ? CVT_PNG : CVT_WMF))
    3436             :         {
    3437             :             pBLIPType = (eGraphicType == GRAPHIC_BITMAP) ?
    3438           0 :                 OOO_STRING_SVTOOLS_RTF_PNGBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
    3439           0 :             aStream.Seek(STREAM_SEEK_TO_END);
    3440           0 :             nSize = aStream.Tell();
    3441           0 :             pGraphicAry = (sal_uInt8*)aStream.GetData();
    3442             :         }
    3443             :     }
    3444             : 
    3445           0 :     Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize());
    3446             : 
    3447           0 :     const SwCropGrf &rCr = (const SwCropGrf &)pGrfNode->GetAttr(RES_GRFATR_CROPGRF);
    3448             : 
    3449             :     //Get original size in twips
    3450           0 :     Size aSize(sw::util::GetSwappedInSize(*pGrfNode));
    3451           0 :     Size aRendered(aSize);
    3452           0 :     if (pFlyFrmFmt)
    3453             :     {
    3454           0 :         const SwFmtFrmSize& rS = pFlyFrmFmt->GetFrmSize();
    3455           0 :         aRendered.Width() = rS.GetWidth();
    3456           0 :         aRendered.Height() = rS.GetHeight();
    3457             :     }
    3458             : 
    3459             :     /*
    3460             :        If the graphic is not of type WMF then we will have to store two
    3461             :        graphics, one in the native format wrapped in shppict, and the other in
    3462             :        the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
    3463             :        a wmf already then we don't need any such wrapping
    3464             :        */
    3465           0 :     bool bIsWMF = pBLIPType && std::strcmp(pBLIPType, OOO_STRING_SVTOOLS_RTF_WMETAFILE) == 0;
    3466           0 :     if (!bIsWMF)
    3467           0 :         m_rExport.Strm() << "{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT;
    3468             : 
    3469           0 :     if (pBLIPType)
    3470           0 :         ExportPICT( pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
    3471             :     else
    3472             :     {
    3473           0 :         aStream.Seek(0);
    3474           0 :         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
    3475           0 :         pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
    3476           0 :         aStream.Seek(STREAM_SEEK_TO_END);
    3477           0 :         nSize = aStream.Tell();
    3478           0 :         pGraphicAry = (sal_uInt8*)aStream.GetData();
    3479             : 
    3480           0 :         ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
    3481             :     }
    3482             : 
    3483           0 :     if (!bIsWMF)
    3484             :     {
    3485           0 :         m_rExport.Strm() << "}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT;
    3486             : 
    3487           0 :         aStream.Seek(0);
    3488           0 :         GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
    3489           0 :         pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
    3490           0 :         aStream.Seek(STREAM_SEEK_TO_END);
    3491           0 :         nSize = aStream.Tell();
    3492           0 :         pGraphicAry = (sal_uInt8*)aStream.GetData();
    3493             : 
    3494           0 :         ExportPICT(pFlyFrmFmt, aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize, m_rExport, &m_rExport.Strm() );
    3495             : 
    3496           0 :         m_rExport.Strm() << '}';
    3497             :     }
    3498             : 
    3499           0 :     m_rExport.Strm() << m_rExport.sNewLine;
    3500          36 : }
    3501             : 
    3502             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10