vmiklos01: #i113532# add RtfExport based on MSWordExportBase
authorMiklos Vajna <vmiklos@openoffice.org>
Thu Jul 29 22:01:25 2010 +0200 (21 months ago)
changeset 272989d26e3e4821e0
parent 272988 66d9c3b3f793
child 272990 bbc02a400d5e
vmiklos01: #i113532# add RtfExport based on MSWordExportBase
sw/source/filter/rtf/swparrtf.cxx
sw/source/filter/rtf/swparrtf.hxx
sw/source/filter/rtf/wrtrtf.cxx
sw/source/filter/ww8/docxexport.cxx
sw/source/filter/ww8/docxexport.hxx
sw/source/filter/ww8/docxexportfilter.cxx
sw/source/filter/ww8/makefile.mk
sw/source/filter/ww8/rtfattributeoutput.cxx
sw/source/filter/ww8/rtfattributeoutput.hxx
sw/source/filter/ww8/rtfexport.cxx
sw/source/filter/ww8/rtfexport.hxx
sw/source/filter/ww8/rtfexportfilter.cxx
sw/source/filter/ww8/rtfexportfilter.hxx
sw/source/filter/ww8/rtfimportfilter.cxx
sw/source/filter/ww8/rtfimportfilter.hxx
sw/source/filter/ww8/rtfsdrexport.cxx
sw/source/filter/ww8/rtfsdrexport.hxx
sw/source/filter/ww8/wrtw8esh.cxx
sw/source/filter/ww8/wrtw8nds.cxx
sw/source/filter/ww8/wrtw8num.cxx
sw/source/filter/ww8/wrtw8sty.cxx
sw/source/filter/ww8/wrtww8.cxx
sw/source/filter/ww8/wrtww8.hxx
sw/source/filter/ww8/ww8atr.cxx
     1.1 --- a/sw/source/filter/rtf/swparrtf.cxx	Thu Jul 29 20:08:54 2010 +0200
     1.2 +++ b/sw/source/filter/rtf/swparrtf.cxx	Thu Jul 29 22:01:25 2010 +0200
     1.3 @@ -179,6 +179,12 @@
     1.4      return nRet;
     1.5  }
     1.6  
     1.7 +ULONG RtfReader::Read(SvStream* pStream, SwDoc& rDoc, const String& rBaseURL, SwPaM& rPam)
     1.8 +{
     1.9 +    pStrm = pStream;
    1.10 +    return Read(rDoc, rBaseURL, rPam, rBaseURL);
    1.11 +}
    1.12 +
    1.13  SwRTFParser::SwRTFParser(SwDoc* pD,
    1.14          uno::Reference<document::XDocumentProperties> i_xDocProps,
    1.15          const SwPaM& rCrsr, SvStream& rIn, const String& rBaseURL,
     2.1 --- a/sw/source/filter/rtf/swparrtf.hxx	Thu Jul 29 20:08:54 2010 +0200
     2.2 +++ b/sw/source/filter/rtf/swparrtf.hxx	Thu Jul 29 22:01:25 2010 +0200
     2.3 @@ -81,6 +81,8 @@
     2.4  class RtfReader: public Reader
     2.5  {
     2.6      virtual ULONG Read( SwDoc &, const String& rBaseURL, SwPaM &,const String &);
     2.7 +public:
     2.8 +    virtual ULONG Read( SvStream* pStrm, SwDoc &, const String& rBaseURL, SwPaM &);
     2.9  };
    2.10  
    2.11  class SwNodeIdx : public SvxNodeIdx
     3.1 --- a/sw/source/filter/rtf/wrtrtf.cxx	Thu Jul 29 20:08:54 2010 +0200
     3.2 +++ b/sw/source/filter/rtf/wrtrtf.cxx	Thu Jul 29 22:01:25 2010 +0200
     3.3 @@ -1748,11 +1748,6 @@
     3.4  	rWrt.bOutSection = bOldOutSection;
     3.5  }
     3.6  
     3.7 -extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportRTF( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
     3.8 -{
     3.9 -    xRet = new SwRTFWriter( rFltName, rBaseURL );
    3.10 -}
    3.11 -
    3.12  short SwRTFWriter::GetCurrentPageDirection() const
    3.13  {
    3.14      const SwFrmFmt  &rFmt = pAktPageDesc
     4.1 --- a/sw/source/filter/ww8/docxexport.cxx	Thu Jul 29 20:08:54 2010 +0200
     4.2 +++ b/sw/source/filter/ww8/docxexport.cxx	Thu Jul 29 22:01:25 2010 +0200
     4.3 @@ -116,131 +116,6 @@
     4.4      return true;
     4.5  }
     4.6  
     4.7 -bool DocxExport::GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt,
     4.8 -                    xub_StrLen nEnd, IMarkVector& rArr )
     4.9 -{
    4.10 -    IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
    4.11 -    ULONG nNd = rNd.GetIndex( );
    4.12 -
    4.13 -    const sal_Int32 nMarks = pMarkAccess->getMarksCount();
    4.14 -    for ( sal_Int32 i = 0; i < nMarks; i++ )
    4.15 -    {
    4.16 -        IMark* pMark = ( pMarkAccess->getMarksBegin() + i )->get();
    4.17 -
    4.18 -        // Only keep the bookmarks starting or ending in this node
    4.19 -        if ( pMark->GetMarkStart().nNode == nNd ||
    4.20 -             pMark->GetMarkEnd().nNode == nNd )
    4.21 -        {
    4.22 -            xub_StrLen nBStart = pMark->GetMarkStart().nContent.GetIndex();
    4.23 -            xub_StrLen nBEnd = pMark->GetMarkEnd().nContent.GetIndex();
    4.24 -
    4.25 -            // Keep only the bookmars starting or ending in the snippet
    4.26 -            bool bIsStartOk = ( nBStart >= nStt ) && ( nBStart <= nEnd );
    4.27 -            bool bIsEndOk = ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
    4.28 -
    4.29 -            if ( bIsStartOk || bIsEndOk )
    4.30 -                rArr.push_back( pMark );
    4.31 -        }
    4.32 -    }
    4.33 -    return ( rArr.size() > 0 );
    4.34 -}
    4.35 -
    4.36 -class CompareMarksEnd : public std::binary_function < const IMark *, const IMark *, bool >
    4.37 -{
    4.38 -public:
    4.39 -    inline bool operator() ( const IMark * pOneB, const IMark * pTwoB ) const
    4.40 -    {
    4.41 -        xub_StrLen nOEnd = pOneB->GetMarkEnd().nContent.GetIndex();
    4.42 -        xub_StrLen nTEnd = pTwoB->GetMarkEnd().nContent.GetIndex();
    4.43 -
    4.44 -        return nOEnd < nTEnd;
    4.45 -    }
    4.46 -};
    4.47 -
    4.48 -bool DocxExport::NearestBookmark( xub_StrLen& rNearest )
    4.49 -{
    4.50 -    bool bHasBookmark = false;
    4.51 -
    4.52 -    if ( m_rSortedMarksStart.size( ) > 0 )
    4.53 -    {
    4.54 -        IMark* pMarkStart = m_rSortedMarksStart.front();
    4.55 -        rNearest = pMarkStart->GetMarkStart().nContent.GetIndex();
    4.56 -        bHasBookmark = true;
    4.57 -    }        
    4.58 -
    4.59 -    if ( m_rSortedMarksEnd.size( ) > 0 )
    4.60 -    {
    4.61 -        IMark* pMarkEnd = m_rSortedMarksEnd[0];
    4.62 -        if ( !bHasBookmark )
    4.63 -            rNearest = pMarkEnd->GetMarkEnd().nContent.GetIndex();
    4.64 -        else
    4.65 -            rNearest = std::min( rNearest, pMarkEnd->GetMarkEnd().nContent.GetIndex() );
    4.66 -        bHasBookmark = true;
    4.67 -    }
    4.68 -
    4.69 -    return bHasBookmark;
    4.70 -}
    4.71 -
    4.72 -xub_StrLen DocxExport::GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos )
    4.73 -{
    4.74 -    // Get the bookmarks for the normal run
    4.75 -    xub_StrLen nNextPos = MSWordExportBase::GetNextPos( pAttrIter, rNode, nAktPos );
    4.76 -
    4.77 -    GetSortedBookmarks( rNode, nAktPos, nNextPos - nAktPos );
    4.78 -
    4.79 -    xub_StrLen nNextBookmark = nNextPos;
    4.80 -    NearestBookmark( nNextPos );
    4.81 -    
    4.82 -    return std::min( nNextPos, nNextBookmark );
    4.83 -}
    4.84 -
    4.85 -void DocxExport::UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd )
    4.86 -{
    4.87 -    xub_StrLen nNextPos;
    4.88 -
    4.89 -    // either no bookmark, or it is not at the current position
    4.90 -    if ( !NearestBookmark( nNextPos ) || nNextPos > nAktPos )
    4.91 -    {
    4.92 -        MSWordExportBase::UpdatePosition( pAttrIter, nAktPos, nEnd );
    4.93 -    }
    4.94 -}
    4.95 -
    4.96 -void DocxExport::GetSortedBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen )
    4.97 -{
    4.98 -    IMarkVector aMarksStart;
    4.99 -    if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarksStart ) ) 
   4.100 -    {
   4.101 -        IMarkVector aSortedEnd;
   4.102 -        IMarkVector aSortedStart;
   4.103 -        for ( IMarkVector::const_iterator it = aMarksStart.begin(), end = aMarksStart.end();
   4.104 -              it < end; ++it )
   4.105 -        {
   4.106 -            IMark* pMark = (*it);
   4.107 -
   4.108 -            // Remove the positions egals to the current pos
   4.109 -            xub_StrLen nStart = pMark->GetMarkStart().nContent.GetIndex();
   4.110 -            xub_StrLen nEnd = pMark->GetMarkEnd().nContent.GetIndex();
   4.111 -
   4.112 -            if ( nStart > nAktPos )
   4.113 -                aSortedStart.push_back( pMark );
   4.114 -
   4.115 -            if ( nEnd > nAktPos )
   4.116 -                aSortedEnd.push_back( pMark );
   4.117 -        }
   4.118 -
   4.119 -        // Sort the bookmarks by end position
   4.120 -        std::sort( aSortedEnd.begin(), aSortedEnd.end(), CompareMarksEnd() );
   4.121 -    
   4.122 -        m_rSortedMarksStart.swap( aSortedStart );
   4.123 -        m_rSortedMarksEnd.swap( aSortedEnd );
   4.124 -    }
   4.125 -    else
   4.126 -    {
   4.127 -        m_rSortedMarksStart.clear( );
   4.128 -        m_rSortedMarksEnd.clear( );
   4.129 -    }
   4.130 -}
   4.131 -
   4.132  void DocxExport::AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen )
   4.133  {
   4.134      std::vector< OUString > aStarts;
     5.1 --- a/sw/source/filter/ww8/docxexport.hxx	Thu Jul 29 20:08:54 2010 +0200
     5.2 +++ b/sw/source/filter/ww8/docxexport.hxx	Thu Jul 29 22:01:25 2010 +0200
     5.3 @@ -76,11 +76,6 @@
     5.4      /// Footer counter.
     5.5      sal_Int32 m_nFooters;
     5.6  
     5.7 -    /// Used to split the runs according to the bookmarks start and ends
     5.8 -    typedef std::vector< ::sw::mark::IMark* > IMarkVector;
     5.9 -    IMarkVector m_rSortedMarksStart;
    5.10 -    IMarkVector m_rSortedMarksEnd;
    5.11 -
    5.12      /// Exporter of the VML shapes.
    5.13      oox::vml::VMLExport *m_pVMLExport;
    5.14  
    5.15 @@ -162,24 +157,7 @@
    5.16                                       const SwFmtPageDesc* pNewPgDescFmt = 0,
    5.17                                       const SwPageDesc* pNewPgDesc = 0 );
    5.18  
    5.19 -    /// Get the next position in the text node to output
    5.20 -    virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
    5.21 -
    5.22 -    /// Update the information for GetNextPos().
    5.23 -    virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
    5.24 -
    5.25  private:
    5.26 -    /// Find the nearest bookmark from the current position.
    5.27 -    ///
    5.28 -    /// Returns false when there is no bookmark.
    5.29 -    bool NearestBookmark( xub_StrLen& rNearest );
    5.30 -    
    5.31 -    void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, 
    5.32 -                xub_StrLen nLen );
    5.33 -
    5.34 -    bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd,
    5.35 -            IMarkVector& rArr );
    5.36 -
    5.37      /// Setup pStyles and write styles.xml 
    5.38      void InitStyles();
    5.39  
     6.1 --- a/sw/source/filter/ww8/docxexportfilter.cxx	Thu Jul 29 20:08:54 2010 +0200
     6.2 +++ b/sw/source/filter/ww8/docxexportfilter.cxx	Thu Jul 29 22:01:25 2010 +0200
     6.3 @@ -26,6 +26,8 @@
     6.4   ************************************************************************/
     6.5  
     6.6  #include "docxexportfilter.hxx"
     6.7 +#include "rtfexportfilter.hxx"
     6.8 +#include "rtfimportfilter.hxx"
     6.9  #include "docxexport.hxx"
    6.10  
    6.11  #include <docsh.hxx>
    6.12 @@ -144,7 +146,35 @@
    6.13          }
    6.14          catch( registry::InvalidRegistryException& )
    6.15          {
    6.16 -            OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
    6.17 +            OSL_ENSURE( sal_False, "### InvalidRegistryException (docx)!" );
    6.18 +        }
    6.19 +
    6.20 +        try
    6.21 +        {
    6.22 +            uno::Reference< registry::XRegistryKey > xNewKey1(
    6.23 +                    static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey(                                
    6.24 +                        OUString::createFromAscii( IMPL_NAME_RTFEXPORT "/UNO/SERVICES/" ) ) );
    6.25 +            xNewKey1->createKey( RtfExport_getSupportedServiceNames().getConstArray()[0] );
    6.26 +
    6.27 +            bRet = sal_True;
    6.28 +        }
    6.29 +        catch( registry::InvalidRegistryException& )
    6.30 +        {
    6.31 +            OSL_ENSURE( sal_False, "### InvalidRegistryException (rtfexport)!" );
    6.32 +        }
    6.33 +
    6.34 +        try
    6.35 +        {
    6.36 +            uno::Reference< registry::XRegistryKey > xNewKey1(
    6.37 +                    static_cast< registry::XRegistryKey* >( pRegistryKey )->createKey(                                
    6.38 +                        OUString::createFromAscii( IMPL_NAME_RTFIMPORT "/UNO/SERVICES/" ) ) );
    6.39 +            xNewKey1->createKey( RtfExport_getSupportedServiceNames().getConstArray()[0] );
    6.40 +
    6.41 +            bRet = sal_True;
    6.42 +        }
    6.43 +        catch( registry::InvalidRegistryException& )
    6.44 +        {
    6.45 +            OSL_ENSURE( sal_False, "### InvalidRegistryException (rtfimport)!" );
    6.46          }
    6.47      }
    6.48  
    6.49 @@ -157,6 +187,7 @@
    6.50  
    6.51  SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
    6.52  {
    6.53 +    OSL_TRACE("%s, pImplName is '%s'", __PRETTY_FUNCTION__, pImplName);
    6.54      uno::Reference< lang::XSingleServiceFactory > xFactory;
    6.55      void* pRet = 0;
    6.56  
    6.57 @@ -169,6 +200,22 @@
    6.58                      DocxExport_getImplementationName(),
    6.59                      DocxExport_createInstance,
    6.60                      DocxExport_getSupportedServiceNames() ) );
    6.61 +    } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFEXPORT ) == 0 ) {
    6.62 +        const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFEXPORT ) );
    6.63 +
    6.64 +        xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
    6.65 +                    reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
    6.66 +                    RtfExport_getImplementationName(),
    6.67 +                    RtfExport_createInstance,
    6.68 +                    RtfExport_getSupportedServiceNames() ) );
    6.69 +    } else if ( rtl_str_compare( pImplName, IMPL_NAME_RTFIMPORT ) == 0 ) {
    6.70 +        const OUString aServiceName( OUString::createFromAscii( IMPL_NAME_RTFIMPORT ) );
    6.71 +
    6.72 +        xFactory = uno::Reference< lang::XSingleServiceFactory >( ::cppu::createSingleFactory(
    6.73 +                    reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ),
    6.74 +                    RtfImport_getImplementationName(),
    6.75 +                    RtfImport_createInstance,
    6.76 +                    RtfImport_getSupportedServiceNames() ) );
    6.77      }
    6.78  
    6.79      if ( xFactory.is() )
     7.1 --- a/sw/source/filter/ww8/makefile.mk	Thu Jul 29 20:08:54 2010 +0200
     7.2 +++ b/sw/source/filter/ww8/makefile.mk	Thu Jul 29 22:01:25 2010 +0200
     7.3 @@ -67,7 +67,12 @@
     7.4          $(SLO)$/WW8TableInfo.obj \
     7.5          $(SLO)$/WW8FFData.obj \
     7.6          $(SLO)$/WW8Sttbf.obj \
     7.7 -		$(SLO)$/WW8FibData.obj
     7.8 +		$(SLO)$/WW8FibData.obj \
     7.9 +		$(SLO)$/rtfexportfilter.obj \
    7.10 +		$(SLO)$/rtfimportfilter.obj \
    7.11 +		$(SLO)$/rtfattributeoutput.obj \
    7.12 +		$(SLO)$/rtfsdrexport.obj \
    7.13 +		$(SLO)$/rtfexport.obj
    7.14  
    7.15  
    7.16  SLOFILES =	\
    7.17 @@ -96,7 +101,12 @@
    7.18          $(SLO)$/WW8TableInfo.obj \
    7.19          $(SLO)$/WW8FFData.obj \
    7.20          $(SLO)$/WW8Sttbf.obj \
    7.21 -		$(SLO)$/WW8FibData.obj
    7.22 +		$(SLO)$/WW8FibData.obj \
    7.23 +		$(SLO)$/rtfexportfilter.obj \
    7.24 +		$(SLO)$/rtfimportfilter.obj \
    7.25 +		$(SLO)$/rtfattributeoutput.obj \
    7.26 +		$(SLO)$/rtfsdrexport.obj \
    7.27 +		$(SLO)$/rtfexport.obj
    7.28  
    7.29  
    7.30  # --- Tagets -------------------------------------------------------
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/sw/source/filter/ww8/rtfattributeoutput.cxx	Thu Jul 29 22:01:25 2010 +0200
     8.3 @@ -0,0 +1,3323 @@
     8.4 +/*************************************************************************
     8.5 + *
     8.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     8.7 + *
     8.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
     8.9 + * Copyright 2010 Miklos Vajna.
    8.10 + *
    8.11 + * OpenOffice.org - a multi-platform office productivity suite
    8.12 + *
    8.13 + * This file is part of OpenOffice.org.
    8.14 + *
    8.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
    8.16 + * it under the terms of the GNU Lesser General Public License version 3
    8.17 + * only, as published by the Free Software Foundation.
    8.18 + *
    8.19 + * OpenOffice.org is distributed in the hope that it will be useful,
    8.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    8.22 + * GNU Lesser General Public License version 3 for more details
    8.23 + * (a copy is included in the LICENSE file that accompanied this code).
    8.24 + *
    8.25 + * You should have received a copy of the GNU Lesser General Public License
    8.26 + * version 3 along with OpenOffice.org.  If not, see
    8.27 + * <http://www.openoffice.org/license.html>
    8.28 + * for a copy of the LGPLv3 License.
    8.29 + *
    8.30 + ************************************************************************/
    8.31 +
    8.32 +#include "rtfattributeoutput.hxx"
    8.33 +#include "rtfexport.hxx"
    8.34 +#include "rtfsdrexport.hxx"
    8.35 +#include "writerwordglue.hxx"
    8.36 +#include "wrtww8.hxx"
    8.37 +#include "ww8par.hxx"
    8.38 +#include "fmtcntnt.hxx"
    8.39 +#include "fmtsrnd.hxx"
    8.40 +#include "fchrfmt.hxx"
    8.41 +#include "tgrditem.hxx"
    8.42 +#include "fmtruby.hxx"
    8.43 +#include "charfmt.hxx"
    8.44 +#include "breakit.hxx"
    8.45 +
    8.46 +#include <i18npool/mslangid.hxx>
    8.47 +
    8.48 +#include <hintids.hxx>
    8.49 +
    8.50 +#include <svtools/poolitem.hxx>
    8.51 +#include <svtools/rtfkeywd.hxx>
    8.52 +
    8.53 +#include <svx/fontitem.hxx>
    8.54 +#include <svx/tstpitem.hxx>
    8.55 +#include <svx/adjitem.hxx>
    8.56 +#include <svx/spltitem.hxx>
    8.57 +#include <svx/widwitem.hxx>
    8.58 +#include <svx/lspcitem.hxx>
    8.59 +#include <svx/keepitem.hxx>
    8.60 +#include <svx/shaditem.hxx>
    8.61 +#include <svx/brshitem.hxx>
    8.62 +#include <svx/postitem.hxx>
    8.63 +#include <svx/wghtitem.hxx>
    8.64 +#include <svx/kernitem.hxx>
    8.65 +#include <svx/crsditem.hxx>
    8.66 +#include <svx/cmapitem.hxx>
    8.67 +#include <svx/wrlmitem.hxx>
    8.68 +#include <svx/udlnitem.hxx>
    8.69 +#include <svx/langitem.hxx>
    8.70 +#include <svx/escpitem.hxx>
    8.71 +#include <svx/fhgtitem.hxx>
    8.72 +#include <svx/colritem.hxx>
    8.73 +#include <svx/hyznitem.hxx>
    8.74 +#include <svx/brkitem.hxx>
    8.75 +#include <svx/lrspitem.hxx>
    8.76 +#include <svx/ulspitem.hxx>
    8.77 +#include <svx/boxitem.hxx>
    8.78 +#include <svx/cntritem.hxx>
    8.79 +#include <svx/shdditem.hxx>
    8.80 +#include <svx/akrnitem.hxx>
    8.81 +#include <svx/pbinitem.hxx>
    8.82 +#include <svx/emphitem.hxx>
    8.83 +#include <svx/twolinesitem.hxx>
    8.84 +#include <svx/charscaleitem.hxx>
    8.85 +#include <svx/charrotateitem.hxx>
    8.86 +#include <svx/charreliefitem.hxx>
    8.87 +#include <svx/paravertalignitem.hxx>
    8.88 +#include <svx/pgrditem.hxx>
    8.89 +#include <svx/frmdiritem.hxx>
    8.90 +#include <svx/blnkitem.hxx>
    8.91 +#include <svx/charhiddenitem.hxx>
    8.92 +#include <svx/svdmodel.hxx>
    8.93 +#include <svx/svdobj.hxx>
    8.94 +#include <svx/fmglob.hxx>
    8.95 +#include <svx/svdouno.hxx>
    8.96 +#include <svx/msoleexp.hxx>
    8.97 +
    8.98 +#include <docufld.hxx>
    8.99 +#include <flddropdown.hxx>
   8.100 +#include <format.hxx>
   8.101 +#include <fmtclds.hxx>
   8.102 +#include <fmtinfmt.hxx>
   8.103 +#include <fmtfld.hxx>
   8.104 +#include <fmtfsize.hxx>
   8.105 +#include <fmtftn.hxx>
   8.106 +#include <fmtrowsplt.hxx>
   8.107 +#include <fmtline.hxx>
   8.108 +#include <fmtanchr.hxx>
   8.109 +#include <frmfmt.hxx>
   8.110 +#include <frmatr.hxx>
   8.111 +#include <ftninfo.hxx>
   8.112 +#include <htmltbl.hxx>
   8.113 +#include <ndgrf.hxx>
   8.114 +#include <ndtxt.hxx>
   8.115 +#include <node.hxx>
   8.116 +#include <pagedesc.hxx>
   8.117 +#include <paratr.hxx>
   8.118 +#include <swmodule.hxx>
   8.119 +#include <swtable.hxx>
   8.120 +#include <txtftn.hxx>
   8.121 +#include <txtinet.hxx>
   8.122 +#include <numrule.hxx>
   8.123 +#include <grfatr.hxx>
   8.124 +#include <ndole.hxx>
   8.125 +#include <lineinfo.hxx>
   8.126 +#include <rtf.hxx>
   8.127 +
   8.128 +#include <rtl/strbuf.hxx>
   8.129 +#include <rtl/ustrbuf.hxx>
   8.130 +#include <rtl/ustring.hxx>
   8.131 +
   8.132 +#include <tools/color.hxx>
   8.133 +
   8.134 +#include <vcl/cvtgrf.hxx>
   8.135 +
   8.136 +#include <com/sun/star/i18n/ScriptType.hdl>
   8.137 +#include <com/sun/star/drawing/XShape.hpp>
   8.138 +#include <com/sun/star/frame/XModel.hpp>
   8.139 +#include <com/sun/star/chart2/XChartDocument.hpp>
   8.140 +#include <com/sun/star/beans/XPropertySet.hpp>
   8.141 +#include <com/sun/star/container/XNamed.hpp>
   8.142 +
   8.143 +#include <osl/diagnose.h>
   8.144 +
   8.145 +using rtl::OString;
   8.146 +using rtl::OStringBuffer;
   8.147 +using rtl::OUString;
   8.148 +using rtl::OUStringBuffer;
   8.149 +using rtl::OUStringToOString;
   8.150 +
   8.151 +using namespace nsSwDocInfoSubType;
   8.152 +using namespace nsFieldFlags;
   8.153 +using namespace sw::util;
   8.154 +using namespace ::com::sun::star;
   8.155 +
   8.156 +static OString OutTBLBorderLine(RtfExport &rExport, const SvxBorderLine* pLine, const sal_Char* pStr)
   8.157 +{
   8.158 +    OStringBuffer aRet;
   8.159 +    aRet.append(pStr);
   8.160 +    if( pLine->GetInWidth() )
   8.161 +    {
   8.162 +        // double line
   8.163 +        aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDB);
   8.164 +        switch( pLine->GetInWidth() )
   8.165 +        {
   8.166 +            case DEF_LINE_WIDTH_0:
   8.167 +                aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "15");
   8.168 +                break;
   8.169 +            case DEF_LINE_WIDTH_1:
   8.170 +                aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "30");
   8.171 +                break;
   8.172 +            case DEF_LINE_WIDTH_2:
   8.173 +            case DEF_LINE_WIDTH_3:
   8.174 +                aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW "45");
   8.175 +                break;
   8.176 +        }
   8.177 +    }
   8.178 +    else
   8.179 +    {
   8.180 +        if ( DEF_LINE_WIDTH_0 == pLine->GetOutWidth( ) )
   8.181 +            // Hairline
   8.182 +            aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRHAIR);
   8.183 +        else if( 255 >= pLine->GetOutWidth() )
   8.184 +        {
   8.185 +            // Simple width simple
   8.186 +            aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRS);
   8.187 +            switch ( pLine->GetStyle( ) )
   8.188 +            {
   8.189 +                case DOTTED:
   8.190 +                    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDOT);
   8.191 +                    break;
   8.192 +                case DASHED:
   8.193 +                    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRDASH);
   8.194 +                    break;
   8.195 +                case SOLID:
   8.196 +                default:
   8.197 +                    break;
   8.198 +            }
   8.199 +            aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW);
   8.200 +            aRet.append((sal_Int32)pLine->GetOutWidth());
   8.201 +        }
   8.202 +        else
   8.203 +        {
   8.204 +            // Shouldn't happen with the OOo default width values
   8.205 +            OString aTmp = aRet.makeStringAndClear();
   8.206 +            aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRTH);
   8.207 +            aRet.append(aTmp);
   8.208 +            aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRW);
   8.209 +            aRet.append((sal_Int32)pLine->GetOutWidth()/2);
   8.210 +        }
   8.211 +    }
   8.212 +
   8.213 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDRCF);
   8.214 +    aRet.append((sal_Int32)rExport.GetColor(pLine->GetColor()));
   8.215 +    return aRet.makeStringAndClear();
   8.216 +}
   8.217 +
   8.218 +static OString OutBorderLine(RtfExport &rExport, const SvxBorderLine* pLine,
   8.219 +    const sal_Char* pStr, USHORT nDist)
   8.220 +{
   8.221 +    OStringBuffer aRet;
   8.222 +    aRet.append(OutTBLBorderLine(rExport, pLine, pStr));
   8.223 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRSP);
   8.224 +    aRet.append((sal_Int32)nDist);
   8.225 +    return aRet.makeStringAndClear();
   8.226 +}
   8.227 +
   8.228 +static OString OutBorderLine( RtfExport &rExport, const SvxBorderLine* pLine,
   8.229 +                            const char* pStr )
   8.230 +{
   8.231 +    OStringBuffer aRet;
   8.232 +    aRet.append(pStr);
   8.233 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNCOL);
   8.234 +    aRet.append((sal_Int32)rExport.GetColor( pLine->GetColor() ) );
   8.235 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNIN);
   8.236 +    aRet.append((sal_Int32)pLine->GetInWidth());
   8.237 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNOUT);
   8.238 +    aRet.append((sal_Int32)pLine->GetOutWidth());
   8.239 +    aRet.append(OOO_STRING_SVTOOLS_RTF_BRDLNDIST);
   8.240 +    aRet.append((sal_Int32)pLine->GetDistance());
   8.241 +    return aRet.makeStringAndClear();
   8.242 +}
   8.243 +
   8.244 +void RtfAttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
   8.245 +{
   8.246 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.247 +    /*
   8.248 +       You would have thought that
   8.249 +       m_rExport.Strm() << (bIsRTL ? OOO_STRING_SVTOOLS_RTF_RTLCH : OOO_STRING_SVTOOLS_RTF_LTRCH); would be sufficent here ,
   8.250 +       but looks like word needs to see the other directional token to be
   8.251 +       satisified that all is kosher, otherwise it seems in ver 2003 to go and
   8.252 +       semi-randomlyly stick strike through about the place. Perhaps
   8.253 +       strikethrough is some ms developers "something is wrong signal" debugging
   8.254 +       code that we're triggering ?
   8.255 +       */
   8.256 +    if (bIsRTL) {
   8.257 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
   8.258 +        m_aRun.append(' ');
   8.259 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
   8.260 +    } else {
   8.261 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_RTLCH);
   8.262 +        m_aRun.append(' ');
   8.263 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_LTRCH);
   8.264 +    }
   8.265 +
   8.266 +    switch (nScript) {
   8.267 +        case i18n::ScriptType::LATIN:
   8.268 +            m_aRun.append(OOO_STRING_SVTOOLS_RTF_LOCH);
   8.269 +            break;
   8.270 +        case i18n::ScriptType::ASIAN:
   8.271 +            m_aRun.append(OOO_STRING_SVTOOLS_RTF_DBCH);
   8.272 +            break;
   8.273 +        case i18n::ScriptType::COMPLEX:
   8.274 +            /* noop */
   8.275 +            break;
   8.276 +        default:
   8.277 +            /* should not happen? */
   8.278 +            break;
   8.279 +    }
   8.280 +}
   8.281 +
   8.282 +void RtfAttributeOutput::StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo )
   8.283 +{
   8.284 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.285 +
   8.286 +    // Output table/table row/table cell starts if needed
   8.287 +    if ( pTextNodeInfo.get() )
   8.288 +    {
   8.289 +        sal_uInt32 nRow = pTextNodeInfo->getRow();
   8.290 +        sal_uInt32 nCell = pTextNodeInfo->getCell();
   8.291 +
   8.292 +        // New cell/row?
   8.293 +        if ( m_nTableDepth > 0 && !m_bTableCellOpen )
   8.294 +        {
   8.295 +            ww8::WW8TableNodeInfoInner::Pointer_t pDeepInner( pTextNodeInfo->getInnerForDepth( m_nTableDepth ) );
   8.296 +            if ( pDeepInner->getCell() == 0 )
   8.297 +                StartTableRow( pDeepInner );
   8.298 +
   8.299 +            StartTableCell( pDeepInner );
   8.300 +        }
   8.301 +
   8.302 +        if ( nRow == 0 && nCell == 0 )
   8.303 +        {
   8.304 +            // Do we have to start the table?
   8.305 +            // [If we are at the rigth depth already, it means that we
   8.306 +            // continue the table cell]
   8.307 +            sal_uInt32 nCurrentDepth = pTextNodeInfo->getDepth();
   8.308 +
   8.309 +            if ( nCurrentDepth > m_nTableDepth )
   8.310 +            {
   8.311 +                // Start all the tables that begin here
   8.312 +                for ( sal_uInt32 nDepth = m_nTableDepth + 1; nDepth <= pTextNodeInfo->getDepth(); ++nDepth )
   8.313 +                {
   8.314 +                    ww8::WW8TableNodeInfoInner::Pointer_t pInner( pTextNodeInfo->getInnerForDepth( nDepth ) );
   8.315 +
   8.316 +                    StartTable( pInner );
   8.317 +                    StartTableRow( pInner );
   8.318 +                    StartTableCell( pInner );
   8.319 +                }
   8.320 +
   8.321 +                m_nTableDepth = nCurrentDepth;
   8.322 +            }
   8.323 +        }
   8.324 +    }
   8.325 +
   8.326 +    OSL_ENSURE(m_aRun.getLength() == 0, "m_aRun is not empty");
   8.327 +}
   8.328 +
   8.329 +void RtfAttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
   8.330 +{
   8.331 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.332 +
   8.333 +    FinishTableRowCell( pTextNodeInfoInner );
   8.334 +
   8.335 +    OStringBuffer aParagraph;
   8.336 +
   8.337 +    aParagraph.append(m_aRun.makeStringAndClear());
   8.338 +    aParagraph.append(m_aAfterRuns.makeStringAndClear());
   8.339 +    if (m_bTblAfterCell)
   8.340 +        m_bTblAfterCell = false;
   8.341 +    else
   8.342 +    {
   8.343 +        aParagraph.append(m_rExport.sNewLine);
   8.344 +        aParagraph.append(OOO_STRING_SVTOOLS_RTF_PAR);
   8.345 +        aParagraph.append(' ');
   8.346 +    }
   8.347 +    if (m_nColBreakNeeded)
   8.348 +    {
   8.349 +        aParagraph.append(OOO_STRING_SVTOOLS_RTF_COLUMN);
   8.350 +        m_nColBreakNeeded = false;
   8.351 +    }
   8.352 +
   8.353 +    if (!m_bBufferSectionHeaders)
   8.354 +        m_rExport.Strm() << aParagraph.makeStringAndClear();
   8.355 +    else
   8.356 +        m_aSectionHeaders.append(aParagraph.makeStringAndClear());
   8.357 +}
   8.358 +
   8.359 +void RtfAttributeOutput::EmptyParagraph()
   8.360 +{
   8.361 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.362 +
   8.363 +    m_rExport.Strm() << m_rExport.sNewLine << OOO_STRING_SVTOOLS_RTF_PAR << ' ';
   8.364 +}
   8.365 +
   8.366 +void RtfAttributeOutput::StartParagraphProperties( const SwTxtNode& rNode )
   8.367 +{
   8.368 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.369 +    OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
   8.370 +
   8.371 +    // output page/section breaks
   8.372 +    SwNodeIndex aNextIndex( rNode, 1 );
   8.373 +    m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
   8.374 +    m_bBufferSectionBreaks = true;
   8.375 +
   8.376 +    // output section headers / footers
   8.377 +    if (!m_bBufferSectionHeaders)
   8.378 +        m_rExport.Strm() << m_aSectionHeaders.makeStringAndClear();
   8.379 +
   8.380 +    if ( aNextIndex.GetNode().IsTxtNode() )
   8.381 +    {
   8.382 +        const SwTxtNode* pTxtNode = static_cast< SwTxtNode* >( &aNextIndex.GetNode() );
   8.383 +        m_rExport.OutputSectionBreaks( pTxtNode->GetpSwAttrSet(), *pTxtNode );
   8.384 +    }
   8.385 +    else if ( aNextIndex.GetNode().IsTableNode() )
   8.386 +    {
   8.387 +        const SwTableNode* pTableNode = static_cast< SwTableNode* >( &aNextIndex.GetNode() );
   8.388 +        const SwFrmFmt *pFmt = pTableNode->GetTable().GetFrmFmt();
   8.389 +        m_rExport.OutputSectionBreaks( &(pFmt->GetAttrSet()), *pTableNode );
   8.390 +    }
   8.391 +    m_bBufferSectionBreaks = false;
   8.392 +
   8.393 +    OStringBuffer aPar;
   8.394 +    aPar.append(OOO_STRING_SVTOOLS_RTF_PARD);
   8.395 +    aPar.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
   8.396 +    aPar.append(' ');
   8.397 +    if (!m_bBufferSectionHeaders)
   8.398 +        m_rExport.Strm() << aPar.makeStringAndClear();
   8.399 +    else
   8.400 +        m_aSectionHeaders.append(aPar.makeStringAndClear());
   8.401 +}
   8.402 +
   8.403 +void RtfAttributeOutput::EndParagraphProperties()
   8.404 +{
   8.405 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.406 +    m_aStyles.append(m_aStylesEnd.makeStringAndClear());
   8.407 +    m_rExport.Strm() << m_aStyles.makeStringAndClear();
   8.408 +}
   8.409 +
   8.410 +void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
   8.411 +{
   8.412 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.413 +
   8.414 +    m_aRun.append('{');
   8.415 +
   8.416 +    // if there is some redlining in the document, output it
   8.417 +    Redline( pRedlineData );
   8.418 +
   8.419 +    OSL_ENSURE(m_aRunText.getLength() == 0, "m_aRunText is not empty");
   8.420 +}
   8.421 +
   8.422 +void RtfAttributeOutput::EndRun()
   8.423 +{
   8.424 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.425 +    m_aRun.append(m_rExport.sNewLine);
   8.426 +    m_aRun.append(m_aRunText.makeStringAndClear());
   8.427 +    m_aRun.append('}');
   8.428 +}
   8.429 +
   8.430 +void RtfAttributeOutput::StartRunProperties()
   8.431 +{
   8.432 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.433 +    OSL_ENSURE(m_aStyles.getLength() == 0, "m_aStyles is not empty");
   8.434 +}
   8.435 +
   8.436 +void RtfAttributeOutput::EndRunProperties( const SwRedlineData* /*pRedlineData*/ )
   8.437 +{
   8.438 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.439 +    m_aStyles.append(m_aStylesEnd.makeStringAndClear());
   8.440 +    m_aRun.append(m_aStyles.makeStringAndClear());
   8.441 +}
   8.442 +
   8.443 +void RtfAttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet )
   8.444 +{
   8.445 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.446 +    RawText( rText, 0, eCharSet );
   8.447 +}
   8.448 +
   8.449 +OStringBuffer& RtfAttributeOutput::RunText()
   8.450 +{
   8.451 +    return m_aRunText;
   8.452 +}
   8.453 +
   8.454 +OStringBuffer& RtfAttributeOutput::Styles()
   8.455 +{
   8.456 +    return m_aStyles;
   8.457 +}
   8.458 +
   8.459 +void RtfAttributeOutput::RawText( const String& rText, bool /*bForceUnicode*/, rtl_TextEncoding eCharSet )
   8.460 +{
   8.461 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.462 +    m_aRunText.append(m_rExport.OutString(rText, eCharSet));
   8.463 +}
   8.464 +
   8.465 +void RtfAttributeOutput::StartRuby( const SwTxtNode& /*rNode*/, xub_StrLen /*nPos*/, const SwFmtRuby& /*rRuby*/ )
   8.466 +{
   8.467 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
   8.468 +}
   8.469 +
   8.470 +void RtfAttributeOutput::EndRuby()
   8.471 +{
   8.472 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
   8.473 +}
   8.474 +
   8.475 +bool RtfAttributeOutput::StartURL( const String& rUrl, const String& rTarget )
   8.476 +{
   8.477 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.478 +
   8.479 +    m_aStyles.append('{');
   8.480 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FIELD);
   8.481 +    m_aStyles.append('{');
   8.482 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
   8.483 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
   8.484 +    m_aStyles.append(" HYPERLINK ");
   8.485 +
   8.486 +    String sURL( rUrl );
   8.487 +    if( sURL.Len() )
   8.488 +    {
   8.489 +        m_aStyles.append("\"");
   8.490 +        m_aStyles.append(m_rExport.OutString( sURL, m_rExport.eCurrentEncoding));
   8.491 +        m_aStyles.append("\" ");
   8.492 +    }
   8.493 +
   8.494 +    if( rTarget.Len() )
   8.495 +    {
   8.496 +        m_aStyles.append("\\\\t \"");
   8.497 +        m_aStyles.append(m_rExport.OutString( rTarget, m_rExport.eCurrentEncoding));
   8.498 +        m_aStyles.append("\" ");
   8.499 +    }
   8.500 +
   8.501 +    m_aStyles.append("}");
   8.502 +    return true;
   8.503 +}
   8.504 +
   8.505 +bool RtfAttributeOutput::EndURL()
   8.506 +{
   8.507 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.508 +
   8.509 +    // close the fldrslt group
   8.510 +    m_aRunText.append('}');
   8.511 +    // close the field group
   8.512 +    m_aRunText.append('}');
   8.513 +    return true;
   8.514 +}
   8.515 +
   8.516 +void RtfAttributeOutput::FieldVanish( const String& /*rTxt*/, ww::eField /*eType*/ )
   8.517 +{
   8.518 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
   8.519 +}
   8.520 +
   8.521 +void RtfAttributeOutput::Redline( const SwRedlineData* pRedline )
   8.522 +{
   8.523 +    if (!pRedline)
   8.524 +        return;
   8.525 +
   8.526 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.527 +
   8.528 +    if (pRedline->GetType() == nsRedlineType_t::REDLINE_INSERT)
   8.529 +    {
   8.530 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVISED);
   8.531 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVAUTH);
   8.532 +        m_aRun.append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
   8.533 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVDTTM);
   8.534 +    }
   8.535 +    else if(pRedline->GetType() == nsRedlineType_t::REDLINE_DELETE)
   8.536 +    {
   8.537 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_DELETED);
   8.538 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVAUTHDEL);
   8.539 +        m_aRun.append((sal_Int32)m_rExport.GetRedline(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor())));
   8.540 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_REVDTTMDEL);
   8.541 +    }
   8.542 +    m_aRun.append((sal_Int32)sw::ms::DateTime2DTTM(pRedline->GetTimeStamp()));
   8.543 +    m_aRun.append(' ');
   8.544 +}
   8.545 +
   8.546 +void RtfAttributeOutput::FormatDrop( const SwTxtNode& /*rNode*/, const SwFmtDrop& /*rSwFmtDrop*/, USHORT /*nStyle*/, ww8::WW8TableNodeInfo::Pointer_t /*pTextNodeInfo*/, ww8::WW8TableNodeInfoInner::Pointer_t /*pTextNodeInfoInner*/ )
   8.547 +{
   8.548 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
   8.549 +}
   8.550 +
   8.551 +void RtfAttributeOutput::ParagraphStyle( USHORT nStyle )
   8.552 +{
   8.553 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.554 +
   8.555 +    OString *pStyle = m_rExport.GetStyle(nStyle);
   8.556 +    OStringBuffer aStyle;
   8.557 +    aStyle.append(OOO_STRING_SVTOOLS_RTF_S);
   8.558 +    aStyle.append((sal_Int32)nStyle);
   8.559 +    if (pStyle)
   8.560 +        aStyle.append(pStyle->getStr());
   8.561 +    if (!m_bBufferSectionHeaders)
   8.562 +        m_rExport.Strm() << aStyle.makeStringAndClear();
   8.563 +    else
   8.564 +        m_aSectionHeaders.append(aStyle.makeStringAndClear());
   8.565 +}
   8.566 +
   8.567 +void RtfAttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
   8.568 +{
   8.569 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.570 +
   8.571 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_INTBL);
   8.572 +    if ( m_nTableDepth > 1 )
   8.573 +    {
   8.574 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ITAP);
   8.575 +        m_aStyles.append((sal_Int32)m_nTableDepth);
   8.576 +    }
   8.577 +}
   8.578 +
   8.579 +void RtfAttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfo*/ )
   8.580 +{
   8.581 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.582 +
   8.583 +    /* noop */
   8.584 +}
   8.585 +
   8.586 +void RtfAttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.587 +{
   8.588 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.589 +
   8.590 +    if ( !m_pTableWrt )
   8.591 +        InitTableHelper( pTableTextNodeInfoInner );
   8.592 +
   8.593 +    const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
   8.594 +    SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
   8.595 +
   8.596 +    m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TROWD);
   8.597 +    TableOrientation( pTableTextNodeInfoInner );
   8.598 +    TableBidi( pTableTextNodeInfoInner );
   8.599 +    TableHeight( pTableTextNodeInfoInner );
   8.600 +    TableCanSplit( pTableTextNodeInfoInner );
   8.601 +
   8.602 +    // Cell margins
   8.603 +    const SvxBoxItem& rBox = pFmt->GetBox( );
   8.604 +    static const USHORT aBorders[] =
   8.605 +    {
   8.606 +        BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
   8.607 +    };
   8.608 +
   8.609 +    static const char* aRowPadNames[] =
   8.610 +    {
   8.611 +        OOO_STRING_SVTOOLS_RTF_TRPADDT, OOO_STRING_SVTOOLS_RTF_TRPADDL, OOO_STRING_SVTOOLS_RTF_TRPADDB, OOO_STRING_SVTOOLS_RTF_TRPADDR
   8.612 +    };
   8.613 +
   8.614 +    static const char* aRowPadUnits[] =
   8.615 +    {
   8.616 +        OOO_STRING_SVTOOLS_RTF_TRPADDFT, OOO_STRING_SVTOOLS_RTF_TRPADDFL, OOO_STRING_SVTOOLS_RTF_TRPADDFB, OOO_STRING_SVTOOLS_RTF_TRPADDFR
   8.617 +    };
   8.618 +
   8.619 +    for (int i = 0; i < 4; ++i)
   8.620 +    {
   8.621 +        m_aRowDefs.append(aRowPadUnits[i]);
   8.622 +        m_aRowDefs.append((sal_Int32)3);
   8.623 +        m_aRowDefs.append(aRowPadNames[i]);
   8.624 +        m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
   8.625 +    }
   8.626 +
   8.627 +    // The cell-dependent properties
   8.628 +    const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
   8.629 +    SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
   8.630 +    SwTwips nSz = 0;
   8.631 +    Point aPt;
   8.632 +    SwRect aRect( pFmt->FindLayoutRect( false, &aPt ));
   8.633 +    SwTwips nPageSize = aRect.Width();
   8.634 +    SwTwips nTblSz = pFmt->GetFrmSize().GetWidth();
   8.635 +    for( USHORT i = 0; i < pRow->GetCells().Count(); i++ )
   8.636 +    {
   8.637 +        SwWriteTableCell *pCell = pRow->GetCells( )[ i ];
   8.638 +        const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
   8.639 +
   8.640 +        pTableTextNodeInfoInner->setCell( i );
   8.641 +        TableCellProperties(pTableTextNodeInfoInner);
   8.642 +
   8.643 +        // Right boundary: this can't be in TableCellProperties as the old
   8.644 +        // value of nSz is needed.
   8.645 +        nSz += pCellFmt->GetFrmSize().GetWidth();
   8.646 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CELLX);
   8.647 +        SwTwips nCalc = nSz;
   8.648 +        nCalc *= nPageSize;
   8.649 +        nCalc /= nTblSz;
   8.650 +        m_aRowDefs.append( (sal_Int32)(pFmt->GetLRSpace().GetLeft() + nCalc) );
   8.651 +    }
   8.652 +}
   8.653 +
   8.654 +void RtfAttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.655 +{
   8.656 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.657 +
   8.658 +    /*
   8.659 +     * The function name is a bit misleading: given that we write borders
   8.660 +     * before each row, we just have borders, not default ones. Additionally,
   8.661 +     * this function actually writes borders for a specific cell only and is
   8.662 +     * called for each cell.
   8.663 +     */
   8.664 +
   8.665 +    const SwTableBox *pTblBox = pTableTextNodeInfoInner->getTableBox( );
   8.666 +    SwFrmFmt *pFmt = pTblBox->GetFrmFmt( );
   8.667 +    const SvxBoxItem& rDefault = pFmt->GetBox( );
   8.668 +    const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
   8.669 +    SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
   8.670 +    SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
   8.671 +    const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
   8.672 +    const SfxPoolItem* pItem;
   8.673 +    if (SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(RES_BOX, TRUE, &pItem))
   8.674 +    {
   8.675 +        const SvxBoxItem& rBox = (SvxBoxItem&)*pItem;
   8.676 +        static const USHORT aBorders[] =
   8.677 +        {
   8.678 +            BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
   8.679 +        };
   8.680 +        static const char* aBorderNames[] =
   8.681 +        {
   8.682 +            OOO_STRING_SVTOOLS_RTF_CLBRDRT, OOO_STRING_SVTOOLS_RTF_CLBRDRL, OOO_STRING_SVTOOLS_RTF_CLBRDRB, OOO_STRING_SVTOOLS_RTF_CLBRDRR
   8.683 +        };
   8.684 +        //Yes left and top are swapped with eachother for cell padding! Because
   8.685 +        //that's what the thunderingly annoying rtf export/import word xp does.
   8.686 +        static const char* aCellPadNames[] =
   8.687 +        {
   8.688 +            OOO_STRING_SVTOOLS_RTF_CLPADL, OOO_STRING_SVTOOLS_RTF_CLPADT, OOO_STRING_SVTOOLS_RTF_CLPADB, OOO_STRING_SVTOOLS_RTF_CLPADR
   8.689 +        };
   8.690 +        static const char* aCellPadUnits[] =
   8.691 +        {
   8.692 +            OOO_STRING_SVTOOLS_RTF_CLPADFL, OOO_STRING_SVTOOLS_RTF_CLPADFT, OOO_STRING_SVTOOLS_RTF_CLPADFB, OOO_STRING_SVTOOLS_RTF_CLPADFR
   8.693 +        };
   8.694 +        for (int i = 0; i < 4; ++i)
   8.695 +        {
   8.696 +            if (const SvxBorderLine* pLn = rBox.GetLine(aBorders[i]))
   8.697 +                m_aRowDefs.append(OutTBLBorderLine(m_rExport, pLn, aBorderNames[i]));
   8.698 +            if (rDefault.GetDistance(aBorders[i]) !=
   8.699 +                    rBox.GetDistance(aBorders[i]))
   8.700 +            {
   8.701 +                m_aRowDefs.append(aCellPadUnits[i]);
   8.702 +                m_aRowDefs.append((sal_Int32)3);
   8.703 +                m_aRowDefs.append(aCellPadNames[i]);
   8.704 +                m_aRowDefs.append((sal_Int32)rBox.GetDistance(aBorders[i]));
   8.705 +            }
   8.706 +        }
   8.707 +    }
   8.708 +}
   8.709 +
   8.710 +void RtfAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.711 +{
   8.712 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.713 +
   8.714 +    const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
   8.715 +    SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
   8.716 +    SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
   8.717 +    const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
   8.718 +    const SfxPoolItem* pItem;
   8.719 +    if( SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(
   8.720 +                RES_BACKGROUND, TRUE, &pItem ))
   8.721 +    {
   8.722 +        const SvxBrushItem& rBack = (SvxBrushItem&)*pItem;
   8.723 +        if( !rBack.GetColor().GetTransparency() )
   8.724 +        {
   8.725 +            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLCBPAT);
   8.726 +            m_aRowDefs.append((sal_Int32)m_rExport.GetColor(rBack.GetColor()));
   8.727 +        }
   8.728 +    }
   8.729 +}
   8.730 +
   8.731 +void RtfAttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.732 +{
   8.733 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.734 +
   8.735 +    const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
   8.736 +    const SwTableLine * pTabLine = pTabBox->GetUpper();
   8.737 +    const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
   8.738 +    const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
   8.739 +
   8.740 +    if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
   8.741 +    {
   8.742 +        sal_Int32 nHeight = 0;
   8.743 +
   8.744 +        switch ( rLSz.GetHeightSizeType() )
   8.745 +        {
   8.746 +            case ATT_FIX_SIZE: nHeight = -rLSz.GetHeight(); break;
   8.747 +            case ATT_MIN_SIZE: nHeight = rLSz.GetHeight(); break;
   8.748 +            default:           break;
   8.749 +        }
   8.750 +
   8.751 +        if ( nHeight )
   8.752 +        {
   8.753 +            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRRH);
   8.754 +            m_aRowDefs.append(nHeight);
   8.755 +        }
   8.756 +    }
   8.757 +}
   8.758 +
   8.759 +void RtfAttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.760 +{
   8.761 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.762 +
   8.763 +    const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
   8.764 +    const SwTableLine * pTabLine = pTabBox->GetUpper();
   8.765 +    const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
   8.766 +    const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit( );
   8.767 +
   8.768 +    // The rtf default is to allow a row to break
   8.769 +    if (rSplittable.GetValue() == 0)
   8.770 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_TRKEEP);
   8.771 +}
   8.772 +
   8.773 +void RtfAttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.774 +{
   8.775 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.776 +
   8.777 +    const SwTable * pTable = pTableTextNodeInfoInner->getTable();
   8.778 +    const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
   8.779 +
   8.780 +    if ( m_rExport.TrueFrameDirection( *pFrmFmt ) != FRMDIR_HORI_RIGHT_TOP )
   8.781 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_LTRROW);
   8.782 +    else
   8.783 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_RTLROW);
   8.784 +}
   8.785 +
   8.786 +void RtfAttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.787 +{
   8.788 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.789 +
   8.790 +    const SwWriteTableRows& aRows = m_pTableWrt->GetRows( );
   8.791 +    SwWriteTableRow *pRow = aRows[ pTableTextNodeInfoInner->getRow( ) ];
   8.792 +    SwWriteTableCell *pCell = pRow->GetCells( )[ pTableTextNodeInfoInner->getCell( ) ];
   8.793 +    const SwFrmFmt *pCellFmt = pCell->GetBox()->GetFrmFmt();
   8.794 +    const SfxPoolItem* pItem;
   8.795 +
   8.796 +    // vertical merges
   8.797 +    if (pCell->GetRowSpan() > 1)
   8.798 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMGF);
   8.799 +    else if (pCell->GetRowSpan() == 0)
   8.800 +        m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVMRG);
   8.801 +
   8.802 +    // vertical alignment
   8.803 +    if( SFX_ITEM_SET == pCellFmt->GetAttrSet().GetItemState(
   8.804 +                RES_VERT_ORIENT, TRUE, &pItem ) )
   8.805 +        switch( ((SwFmtVertOrient*)pItem)->GetVertOrient() )
   8.806 +        {
   8.807 +            case text::VertOrientation::CENTER: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALC); break;
   8.808 +            case text::VertOrientation::BOTTOM: m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALB); break;
   8.809 +            default:                            m_aRowDefs.append(OOO_STRING_SVTOOLS_RTF_CLVERTALT); break;
   8.810 +        }
   8.811 +}
   8.812 +
   8.813 +void RtfAttributeOutput::TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t /*pNodeInfo*/ )
   8.814 +{
   8.815 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.816 +
   8.817 +    /* noop */
   8.818 +}
   8.819 +
   8.820 +void RtfAttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
   8.821 +{
   8.822 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.823 +
   8.824 +    // This is called when the nested table ends in a cell, and there's no
   8.825 +    // paragraph benhind that; so we must check for the ends of cell, rows,
   8.826 +    // and tables
   8.827 +    // ['true' to write an empty paragraph, MS Word insists on that]
   8.828 +    FinishTableRowCell( pNodeInfoInner, true );
   8.829 +}
   8.830 +
   8.831 +void RtfAttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.832 +{
   8.833 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.834 +
   8.835 +    const SwTable *pTable = pTableTextNodeInfoInner->getTable();
   8.836 +    SwFrmFmt *pFmt = pTable->GetFrmFmt( );
   8.837 +
   8.838 +    OStringBuffer aTblAdjust( OOO_STRING_SVTOOLS_RTF_TRQL );
   8.839 +    switch (pFmt->GetHoriOrient().GetHoriOrient())
   8.840 +    {
   8.841 +        case text::HoriOrientation::CENTER:
   8.842 +            aTblAdjust.setLength(0);
   8.843 +            aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQC);
   8.844 +            break;
   8.845 +        case text::HoriOrientation::RIGHT:
   8.846 +            aTblAdjust.setLength(0);
   8.847 +            aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRQR);
   8.848 +            break;
   8.849 +        case text::HoriOrientation::NONE:
   8.850 +        case text::HoriOrientation::LEFT_AND_WIDTH:
   8.851 +            aTblAdjust.append(OOO_STRING_SVTOOLS_RTF_TRLEFT);
   8.852 +            aTblAdjust.append((sal_Int32)pFmt->GetLRSpace().GetLeft());
   8.853 +            break;
   8.854 +        default:
   8.855 +            break;
   8.856 +    }
   8.857 +
   8.858 +    m_aRowDefs.append(aTblAdjust.makeStringAndClear());
   8.859 +}
   8.860 +
   8.861 +void RtfAttributeOutput::TableRowEnd( sal_uInt32 /*nDepth*/ )
   8.862 +{
   8.863 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.864 +
   8.865 +    /* noop, see EndTableRow() */
   8.866 +}
   8.867 +
   8.868 +/*
   8.869 + * Our private table methods.
   8.870 + */
   8.871 +
   8.872 +void RtfAttributeOutput::InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.873 +{
   8.874 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.875 +
   8.876 +    sal_uInt32 nPageSize = 0;
   8.877 +    bool bRelBoxSize = false;
   8.878 +
   8.879 +    // Create the SwWriteTable instance to use col spans
   8.880 +    GetTablePageSize( pTableTextNodeInfoInner, nPageSize, bRelBoxSize );
   8.881 +
   8.882 +    const SwTable* pTable = pTableTextNodeInfoInner->getTable( );
   8.883 +    const SwFrmFmt *pFmt = pTable->GetFrmFmt( );
   8.884 +    SwTwips nTblSz = pFmt->GetFrmSize( ).GetWidth( );
   8.885 +    
   8.886 +    const SwHTMLTableLayout *pLayout = pTable->GetHTMLTableLayout();
   8.887 +    if( pLayout && pLayout->IsExportable() )
   8.888 +        m_pTableWrt = new SwWriteTable( pLayout );
   8.889 +    else
   8.890 +        m_pTableWrt = new SwWriteTable( pTable->GetTabLines(), (USHORT)nPageSize, 
   8.891 +                (USHORT)nTblSz, false);
   8.892 +}
   8.893 +
   8.894 +void RtfAttributeOutput::StartTable( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
   8.895 +{
   8.896 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.897 +
   8.898 +    /* noop */
   8.899 +}
   8.900 +
   8.901 +void RtfAttributeOutput::StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.902 +{
   8.903 +    sal_uInt32 nCurrentDepth = pTableTextNodeInfoInner->getDepth();
   8.904 +    OSL_TRACE("%s, (depth is %d)", __PRETTY_FUNCTION__, (int)nCurrentDepth);
   8.905 +
   8.906 +    TableDefinition(pTableTextNodeInfoInner);
   8.907 +
   8.908 +    // We'll write the table definition for nested tables later
   8.909 +    if ( nCurrentDepth > 1 )
   8.910 +        return;
   8.911 +    m_rExport.Strm() << m_aRowDefs.makeStringAndClear();
   8.912 +}
   8.913 +
   8.914 +void RtfAttributeOutput::StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner*/ )
   8.915 +{
   8.916 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.917 +
   8.918 +    m_bTableCellOpen = true;
   8.919 +}
   8.920 +
   8.921 +void RtfAttributeOutput::TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
   8.922 +{
   8.923 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.924 +
   8.925 +    TableDefaultBorders(pTableTextNodeInfoInner);
   8.926 +    TableBackgrounds(pTableTextNodeInfoInner);
   8.927 +    TableVerticalCell(pTableTextNodeInfoInner);
   8.928 +}
   8.929 +
   8.930 +void RtfAttributeOutput::EndTableCell( )
   8.931 +{
   8.932 +    OSL_TRACE("%s, (depth is %d)", __PRETTY_FUNCTION__, (int)m_nTableDepth);
   8.933 +
   8.934 +    if ( m_nTableDepth > 1 )
   8.935 +        m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTCELL);
   8.936 +    else
   8.937 +        m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_CELL);
   8.938 +
   8.939 +    m_bTableCellOpen = false;
   8.940 +    m_bTblAfterCell = true;
   8.941 +}
   8.942 +
   8.943 +void RtfAttributeOutput::EndTableRow( )
   8.944 +{
   8.945 +    OSL_TRACE("%s, (depth is %d)", __PRETTY_FUNCTION__, (int)m_nTableDepth);
   8.946 +
   8.947 +    if ( m_nTableDepth > 1 )
   8.948 +    {
   8.949 +        m_aAfterRuns.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_NESTTABLEPROPRS);
   8.950 +        m_aAfterRuns.append(m_aRowDefs.makeStringAndClear());
   8.951 +        m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_NESTROW "}" "{" OOO_STRING_SVTOOLS_RTF_NONESTTABLES OOO_STRING_SVTOOLS_RTF_PAR "}");
   8.952 +    }
   8.953 +    else
   8.954 +        m_aAfterRuns.append(OOO_STRING_SVTOOLS_RTF_ROW);
   8.955 +}
   8.956 +
   8.957 +void RtfAttributeOutput::EndTable()
   8.958 +{
   8.959 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.960 +
   8.961 +    if ( m_nTableDepth > 0 )
   8.962 +        m_nTableDepth--;
   8.963 +
   8.964 +    // We closed the table; if it is a nested table, the cell that contains it
   8.965 +    // still continues
   8.966 +    m_bTableCellOpen = true;
   8.967 +
   8.968 +    // Cleans the table helper
   8.969 +    delete m_pTableWrt, m_pTableWrt = NULL;
   8.970 +}
   8.971 +
   8.972 +void RtfAttributeOutput::FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool /*bForceEmptyParagraph*/ )
   8.973 +{
   8.974 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   8.975 +
   8.976 +    if ( pInner.get() )
   8.977 +    {
   8.978 +        // Where are we in the table
   8.979 +        sal_uInt32 nRow = pInner->getRow( );
   8.980 +
   8.981 +        const SwTable *pTable = pInner->getTable( );
   8.982 +        const SwTableLines& rLines = pTable->GetTabLines( );
   8.983 +        USHORT nLinesCount = rLines.Count( );
   8.984 +
   8.985 +        if ( pInner->isEndOfCell() )
   8.986 +            EndTableCell();
   8.987 +
   8.988 +        // This is a line end
   8.989 +        if ( pInner->isEndOfLine() )
   8.990 +            EndTableRow();
   8.991 +
   8.992 +        // This is the end of the table
   8.993 +        if ( pInner->isEndOfLine( ) && ( nRow + 1 ) == nLinesCount )
   8.994 +            EndTable();
   8.995 +    }
   8.996 +}
   8.997 +
   8.998 +void RtfAttributeOutput::StartStyles()
   8.999 +{
  8.1000 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1001 +    m_rExport.Strm() << m_rExport.sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_COLORTBL;
  8.1002 +    m_rExport.OutColorTable();
  8.1003 +    OSL_ENSURE(m_aStylesheet.getLength() == 0, "m_aStylesheet is not empty");
  8.1004 +    m_aStylesheet.append(m_rExport.sNewLine);
  8.1005 +    m_aStylesheet.append('{');
  8.1006 +    m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_STYLESHEET);
  8.1007 +}
  8.1008 +
  8.1009 +void RtfAttributeOutput::EndStyles( USHORT /*nNumberOfStyles*/ )
  8.1010 +{
  8.1011 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1012 +    m_rExport.Strm() << '}';
  8.1013 +    m_rExport.Strm() << m_aStylesheet.makeStringAndClear();
  8.1014 +    m_rExport.Strm() << '}';
  8.1015 +}
  8.1016 +
  8.1017 +void RtfAttributeOutput::DefaultStyle( USHORT /*nStyle*/ )
  8.1018 +{
  8.1019 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1020 +
  8.1021 +    /* noop, the default style is always 0 in RTF */
  8.1022 +}
  8.1023 +
  8.1024 +void RtfAttributeOutput::StartStyle( const String& rName, bool /*bPapFmt*/,
  8.1025 +        USHORT nBase, USHORT nNext, USHORT /*nWwId*/, USHORT nId, bool /*bAutoUpdate*/ )
  8.1026 +{
  8.1027 +    OSL_TRACE("%s, rName = '%s'", __PRETTY_FUNCTION__,
  8.1028 +            OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ).getStr());
  8.1029 +
  8.1030 +    m_aStylesheet.append('{');
  8.1031 +    m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_S);
  8.1032 +    m_aStylesheet.append( (sal_Int32)nId );
  8.1033 +
  8.1034 +    if ( nBase != 0x0FFF )
  8.1035 +    {
  8.1036 +        m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SBASEDON);
  8.1037 +        m_aStylesheet.append((sal_Int32)nBase);
  8.1038 +    }
  8.1039 +
  8.1040 +    m_aStylesheet.append(OOO_STRING_SVTOOLS_RTF_SNEXT);
  8.1041 +    m_aStylesheet.append((sal_Int32)nNext);
  8.1042 +
  8.1043 +    m_rStyleName = rName;
  8.1044 +    m_nStyleId = nId;
  8.1045 +}
  8.1046 +
  8.1047 +void RtfAttributeOutput::EndStyle()
  8.1048 +{
  8.1049 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1050 +    m_aStyles.append(m_aStylesEnd.makeStringAndClear());
  8.1051 +    OString aStyles = m_aStyles.makeStringAndClear();
  8.1052 +    m_rExport.InsStyle(m_nStyleId, aStyles);
  8.1053 +    m_aStylesheet.append(aStyles);
  8.1054 +    m_aStylesheet.append(' ');
  8.1055 +    m_aStylesheet.append(OUStringToOString( OUString( m_rStyleName ), m_rExport.eCurrentEncoding ));
  8.1056 +    m_aStylesheet.append(";}");
  8.1057 +    m_aStylesheet.append(m_rExport.sNewLine);
  8.1058 +}
  8.1059 +
  8.1060 +void RtfAttributeOutput::StartStyleProperties( bool /*bParProp*/, USHORT /*nStyle*/ )
  8.1061 +{
  8.1062 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1063 +    /* noop */
  8.1064 +}
  8.1065 +
  8.1066 +void RtfAttributeOutput::EndStyleProperties( bool /*bParProp*/ )
  8.1067 +{
  8.1068 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1069 +    /* noop */
  8.1070 +}
  8.1071 +
  8.1072 +void RtfAttributeOutput::OutlineNumbering( BYTE nLvl, const SwNumFmt& /*rNFmt*/, const SwFmt& /*rFmt*/ )
  8.1073 +{
  8.1074 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1075 +
  8.1076 +    if ( nLvl >= WW8ListManager::nMaxLevel )
  8.1077 +        nLvl = WW8ListManager::nMaxLevel - 1;
  8.1078 +
  8.1079 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LEVEL);
  8.1080 +    m_aStyles.append((sal_Int32)nLvl);
  8.1081 +}
  8.1082 +
  8.1083 +void RtfAttributeOutput::PageBreakBefore( bool bBreak )
  8.1084 +{
  8.1085 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1086 +
  8.1087 +    if (bBreak)
  8.1088 +    {
  8.1089 +        m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_PAGEBB;
  8.1090 +    }
  8.1091 +}
  8.1092 +
  8.1093 +void RtfAttributeOutput::SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo )
  8.1094 +{
  8.1095 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1096 +
  8.1097 +    switch (nC)
  8.1098 +    {
  8.1099 +        case msword::ColumnBreak:
  8.1100 +            m_nColBreakNeeded = true;
  8.1101 +            break;
  8.1102 +        case msword::PageBreak:
  8.1103 +            if ( pSectionInfo )
  8.1104 +                m_rExport.SectionProperties( *pSectionInfo );
  8.1105 +            break;
  8.1106 +    }
  8.1107 +}
  8.1108 +
  8.1109 +void RtfAttributeOutput::StartSection()
  8.1110 +{
  8.1111 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1112 +
  8.1113 +    m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECT OOO_STRING_SVTOOLS_RTF_SECTD);
  8.1114 +    if (!m_bBufferSectionBreaks)
  8.1115 +        m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
  8.1116 +}
  8.1117 +
  8.1118 +void RtfAttributeOutput::EndSection()
  8.1119 +{
  8.1120 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1121 +
  8.1122 +    /*
  8.1123 +     * noop, \sect must go to StartSection or Word won't notice multiple
  8.1124 +     * columns...
  8.1125 +     */
  8.1126 +}
  8.1127 +
  8.1128 +void RtfAttributeOutput::SectionFormProtection( bool bProtected )
  8.1129 +{
  8.1130 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1131 +
  8.1132 +    m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED);
  8.1133 +    m_aSectionBreaks.append((sal_Int32)!bProtected);
  8.1134 +}
  8.1135 +
  8.1136 +void RtfAttributeOutput::SectionLineNumbering( ULONG /*nRestartNo*/, const SwLineNumberInfo& rLnNumInfo )
  8.1137 +{
  8.1138 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1139 +
  8.1140 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEMOD;
  8.1141 +    m_rExport.OutLong(rLnNumInfo.GetCountBy());
  8.1142 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINEX;
  8.1143 +    m_rExport.OutLong(rLnNumInfo.GetPosFromLeft());
  8.1144 +    if (!rLnNumInfo.IsRestartEachPage())
  8.1145 +        m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LINECONT;
  8.1146 +}
  8.1147 +
  8.1148 +void RtfAttributeOutput::SectionTitlePage()
  8.1149 +{
  8.1150 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1151 +
  8.1152 +    /*
  8.1153 +     * noop, handled in RtfExport::WriteHeaderFooter()
  8.1154 +     */
  8.1155 +}
  8.1156 +
  8.1157 +void RtfAttributeOutput::SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* /*pFirstPageFmt*/ )
  8.1158 +{
  8.1159 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1160 +
  8.1161 +    const SvxBoxItem& rBox = pFmt->GetBox();
  8.1162 +    const SvxBorderLine *pLine = rBox.GetTop();
  8.1163 +    if(pLine)
  8.1164 +        m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
  8.1165 +                    OOO_STRING_SVTOOLS_RTF_PGBRDRT,
  8.1166 +                    rBox.GetDistance(BOX_LINE_TOP) ));
  8.1167 +    pLine = rBox.GetBottom();
  8.1168 +    if(pLine)
  8.1169 +        m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
  8.1170 +                    OOO_STRING_SVTOOLS_RTF_PGBRDRB,
  8.1171 +                    rBox.GetDistance(BOX_LINE_BOTTOM) ));
  8.1172 +    pLine = rBox.GetLeft();
  8.1173 +    if(pLine)
  8.1174 +        m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
  8.1175 +                    OOO_STRING_SVTOOLS_RTF_PGBRDRL,
  8.1176 +                    rBox.GetDistance(BOX_LINE_LEFT) ));
  8.1177 +    pLine = rBox.GetRight();
  8.1178 +    if(pLine)
  8.1179 +        m_aSectionBreaks.append(OutBorderLine( m_rExport, pLine,
  8.1180 +                    OOO_STRING_SVTOOLS_RTF_PGBRDRR,
  8.1181 +                    rBox.GetDistance(BOX_LINE_RIGHT) ));
  8.1182 +}
  8.1183 +
  8.1184 +void RtfAttributeOutput::SectionBiDi( bool bBiDi )
  8.1185 +{
  8.1186 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1187 +
  8.1188 +    m_rExport.Strm() << (bBiDi ? OOO_STRING_SVTOOLS_RTF_RTLSECT : OOO_STRING_SVTOOLS_RTF_LTRSECT);
  8.1189 +}
  8.1190 +
  8.1191 +void RtfAttributeOutput::SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber )
  8.1192 +{
  8.1193 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1194 +
  8.1195 +    if (nPageRestartNumber > 0)
  8.1196 +    {
  8.1197 +        m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNSTARTS);
  8.1198 +        m_aSectionBreaks.append((sal_Int32)nPageRestartNumber);
  8.1199 +        m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGNRESTART);
  8.1200 +    }
  8.1201 +
  8.1202 +    const char* pStr = 0;
  8.1203 +    switch ( nNumType )
  8.1204 +    {
  8.1205 +        case SVX_NUM_CHARS_UPPER_LETTER:
  8.1206 +        case SVX_NUM_CHARS_UPPER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNUCLTR; break;
  8.1207 +        case SVX_NUM_CHARS_LOWER_LETTER:
  8.1208 +        case SVX_NUM_CHARS_LOWER_LETTER_N:  pStr = OOO_STRING_SVTOOLS_RTF_PGNLCLTR; break;
  8.1209 +        case SVX_NUM_ROMAN_UPPER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNUCRM;  break;
  8.1210 +        case SVX_NUM_ROMAN_LOWER:           pStr = OOO_STRING_SVTOOLS_RTF_PGNLCRM;  break;
  8.1211 +
  8.1212 +        case SVX_NUM_ARABIC:                pStr = OOO_STRING_SVTOOLS_RTF_PGNDEC;     break;
  8.1213 +    }
  8.1214 +    if (pStr)
  8.1215 +        m_aSectionBreaks.append(pStr);
  8.1216 +}
  8.1217 +
  8.1218 +void RtfAttributeOutput::SectionType( BYTE nBreakCode )
  8.1219 +{
  8.1220 +    OSL_TRACE("%s, nBreakCode = %d", __PRETTY_FUNCTION__, nBreakCode);
  8.1221 +
  8.1222 +    /*
  8.1223 +     * break code:   0 No break, 1 New column
  8.1224 +     * 2 New page, 3 Even page, 4 Odd page
  8.1225 +     */
  8.1226 +    const char* sType = NULL;
  8.1227 +    switch ( nBreakCode )
  8.1228 +    {
  8.1229 +        case 1:  sType = OOO_STRING_SVTOOLS_RTF_SBKCOL; break;
  8.1230 +        case 2:  sType = OOO_STRING_SVTOOLS_RTF_SBKPAGE; break;
  8.1231 +        case 3:  sType = OOO_STRING_SVTOOLS_RTF_SBKEVEN; break;
  8.1232 +        case 4:  sType = OOO_STRING_SVTOOLS_RTF_SBKODD; break;
  8.1233 +        default: sType = OOO_STRING_SVTOOLS_RTF_SBKNONE; break;
  8.1234 +    }
  8.1235 +    m_aSectionBreaks.append(sType);
  8.1236 +    if (!m_bBufferSectionBreaks)
  8.1237 +        m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
  8.1238 +}
  8.1239 +
  8.1240 +void RtfAttributeOutput::NumberingDefinition( USHORT nId, const SwNumRule &/*rRule*/ )
  8.1241 +{
  8.1242 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1243 +
  8.1244 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDE;
  8.1245 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
  8.1246 +    m_rExport.OutULong(nId);
  8.1247 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDECOUNT << '0';
  8.1248 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LS;
  8.1249 +    m_rExport.OutULong(nId-1) << '}';
  8.1250 +}
  8.1251 +
  8.1252 +void RtfAttributeOutput::StartAbstractNumbering( USHORT nId )
  8.1253 +{
  8.1254 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1255 +
  8.1256 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LIST << OOO_STRING_SVTOOLS_RTF_LISTTEMPLATEID;
  8.1257 +    m_rExport.OutULong( nId );
  8.1258 +    m_nListId = nId;
  8.1259 +}
  8.1260 +
  8.1261 +void RtfAttributeOutput::EndAbstractNumbering()
  8.1262 +{
  8.1263 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1264 +
  8.1265 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LISTID;
  8.1266 +    m_rExport.OutULong( m_nListId ) << '}' << m_rExport.sNewLine;
  8.1267 +}
  8.1268 +
  8.1269 +void RtfAttributeOutput::NumberingLevel( BYTE nLevel,
  8.1270 +        USHORT nStart,
  8.1271 +        USHORT nNumberingType,
  8.1272 +        SvxAdjust eAdjust,
  8.1273 +        const BYTE * pNumLvlPos,
  8.1274 +        BYTE /*nFollow*/,
  8.1275 +        const wwFont * pFont,
  8.1276 +        const SfxItemSet * pOutSet,
  8.1277 +        sal_Int16 nIndentAt,
  8.1278 +        sal_Int16 nFirstLineIndex,
  8.1279 +        sal_Int16 /*nListTabPos*/,
  8.1280 +        const String &rNumberingString )
  8.1281 +{
  8.1282 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1283 +
  8.1284 +    m_rExport.Strm() << m_rExport.sNewLine;
  8.1285 +    if( nLevel > 8 ) // RTF knows only 9 levels
  8.1286 +        m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_SOUTLVL;
  8.1287 +
  8.1288 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTLEVEL;
  8.1289 +
  8.1290 +    USHORT nVal = 0;
  8.1291 +    switch( nNumberingType )
  8.1292 +    {
  8.1293 +        case SVX_NUM_ROMAN_UPPER:                   nVal = 1;       break;
  8.1294 +        case SVX_NUM_ROMAN_LOWER:                   nVal = 2;       break;
  8.1295 +        case SVX_NUM_CHARS_UPPER_LETTER:
  8.1296 +        case SVX_NUM_CHARS_UPPER_LETTER_N:  nVal = 3;       break;
  8.1297 +        case SVX_NUM_CHARS_LOWER_LETTER:
  8.1298 +        case SVX_NUM_CHARS_LOWER_LETTER_N:  nVal = 4;       break;
  8.1299 +
  8.1300 +        case SVX_NUM_BITMAP:
  8.1301 +        case SVX_NUM_CHAR_SPECIAL:                  nVal = 23;      break;
  8.1302 +    }
  8.1303 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELNFC;
  8.1304 +    m_rExport.OutULong( nVal );
  8.1305 +
  8.1306 +    switch( eAdjust )
  8.1307 +    {
  8.1308 +        case SVX_ADJUST_CENTER:             nVal = 1;       break;
  8.1309 +        case SVX_ADJUST_RIGHT:              nVal = 2;       break;
  8.1310 +        default:                            nVal = 0;       break;
  8.1311 +    }
  8.1312 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELJC;
  8.1313 +    m_rExport.OutULong( nVal );
  8.1314 +
  8.1315 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELSTARTAT;
  8.1316 +    m_rExport.OutULong( nStart );
  8.1317 +
  8.1318 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_LEVELFOLLOW << "0";
  8.1319 +
  8.1320 +    // leveltext group
  8.1321 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LEVELTEXT << ' ';
  8.1322 +
  8.1323 +    if( SVX_NUM_CHAR_SPECIAL == nNumberingType ||
  8.1324 +            SVX_NUM_BITMAP == nNumberingType )
  8.1325 +    {
  8.1326 +        m_rExport.Strm() << "\\'01";
  8.1327 +        sal_Unicode cChar = rNumberingString.GetChar(0);
  8.1328 +        m_rExport.Strm() << "\\u";
  8.1329 +        m_rExport.OutULong(cChar);
  8.1330 +        m_rExport.Strm() << " ?";
  8.1331 +    }
  8.1332 +    else
  8.1333 +    {
  8.1334 +        m_rExport.Strm() << "\\'" << m_rExport.OutHex( rNumberingString.Len(), 2 );
  8.1335 +        m_rExport.Strm() << m_rExport.OutString( rNumberingString, m_rExport.eDefaultEncoding );
  8.1336 +    }
  8.1337 +
  8.1338 +    m_rExport.Strm() << ";}";
  8.1339 +
  8.1340 +    // write the levelnumbers
  8.1341 +    m_rExport.Strm() << "{" << OOO_STRING_SVTOOLS_RTF_LEVELNUMBERS;
  8.1342 +    for( BYTE i = 0; i <= nLevel && pNumLvlPos[ i ]; ++i )
  8.1343 +    {
  8.1344 +        m_rExport.Strm() << "\\'" << m_rExport.OutHex(pNumLvlPos[ i ], 2).getStr();
  8.1345 +    }
  8.1346 +    m_rExport.Strm() << ";}";
  8.1347 +
  8.1348 +    if( pOutSet )
  8.1349 +    {
  8.1350 +        if (pFont)
  8.1351 +        {
  8.1352 +            m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_F;
  8.1353 +            m_rExport.OutULong(m_rExport.maFontHelper.GetId(*pFont));
  8.1354 +        }
  8.1355 +        m_rExport.OutputItemSet( *pOutSet, false, true, i18n::ScriptType::LATIN );
  8.1356 +        m_rExport.Strm() << m_aStyles.makeStringAndClear();
  8.1357 +    }
  8.1358 +
  8.1359 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FI;
  8.1360 +    m_rExport.OutLong( nFirstLineIndex ) << OOO_STRING_SVTOOLS_RTF_LI;
  8.1361 +    m_rExport.OutLong( nIndentAt );
  8.1362 +    
  8.1363 +    m_rExport.Strm() << '}';
  8.1364 +    if( nLevel > 8 )
  8.1365 +        m_rExport.Strm() << '}';
  8.1366 +}
  8.1367 +
  8.1368 +void RtfAttributeOutput::WriteField_Impl( const SwField* pFld, ww::eField /*eType*/, const String& rFldCmd, BYTE /*nMode*/ )
  8.1369 +{
  8.1370 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1371 +
  8.1372 +    // NEEDSWORK this has beeen tested only with page numbers
  8.1373 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
  8.1374 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST " ");
  8.1375 +    m_aRunText.append(m_rExport.OutString(rFldCmd, m_rExport.eCurrentEncoding));
  8.1376 +    m_aRunText.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
  8.1377 +    if (pFld)
  8.1378 +        m_aRunText.append(m_rExport.OutString(pFld->Expand(), m_rExport.eDefaultEncoding));
  8.1379 +    m_aRunText.append("}}");
  8.1380 +}
  8.1381 +
  8.1382 +void RtfAttributeOutput::WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds )
  8.1383 +{
  8.1384 +    for ( std::vector< OUString >::const_iterator it = rStarts.begin(), end = rStarts.end(); it < end; ++it )
  8.1385 +    {
  8.1386 +        m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKSTART " ");
  8.1387 +        m_aRun.append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
  8.1388 +        m_aRun.append('}');
  8.1389 +    }
  8.1390 +    rStarts.clear();
  8.1391 +
  8.1392 +    for ( std::vector< OUString >::const_iterator it = rEnds.begin(), end = rEnds.end(); it < end; ++it )
  8.1393 +    {
  8.1394 +        m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_BKMKEND " ");
  8.1395 +        m_aRun.append(m_rExport.OutString(*it, m_rExport.eCurrentEncoding));
  8.1396 +        m_aRun.append('}');
  8.1397 +    }
  8.1398 +    rEnds.clear();
  8.1399 +}
  8.1400 +
  8.1401 +void RtfAttributeOutput::WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr )
  8.1402 +{
  8.1403 +    OStringBuffer aSectionBreaks = m_aSectionBreaks;
  8.1404 +    m_aSectionBreaks.setLength(0);
  8.1405 +    OStringBuffer aRun = m_aRun;
  8.1406 +    m_aRun.setLength(0);
  8.1407 +
  8.1408 +    m_aSectionHeaders.append(bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
  8.1409 +    m_aSectionHeaders.append((sal_Int32)m_rExport.pAktPageDesc->GetMaster().GetULSpace().GetUpper());
  8.1410 +    m_aSectionHeaders.append('{');
  8.1411 +    m_aSectionHeaders.append(pStr);
  8.1412 +    m_bBufferSectionHeaders = true;
  8.1413 +    m_rExport.WriteHeaderFooterText(rFmt, bHeader);
  8.1414 +    m_bBufferSectionHeaders = false;
  8.1415 +    m_aSectionHeaders.append('}');
  8.1416 +
  8.1417 +    m_aSectionBreaks = aSectionBreaks;
  8.1418 +    m_aRun = aRun;
  8.1419 +}
  8.1420 +
  8.1421 +void RtfAttributeOutput::OutputFlyFrame_Impl( const sw::Frame& rFrame, const Point& /*rNdTopLeft*/ )
  8.1422 +{
  8.1423 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1424 +
  8.1425 +    const SwNode *pNode = rFrame.GetContent();
  8.1426 +    const SwGrfNode *pGrfNode = pNode ? pNode->GetGrfNode() : 0;
  8.1427 +
  8.1428 +    switch ( rFrame.GetWriterType() )
  8.1429 +    {
  8.1430 +        case sw::Frame::eGraphic:
  8.1431 +            if (!rFrame.IsInline())
  8.1432 +            {
  8.1433 +                m_rExport.mpParentFrame = &rFrame;
  8.1434 +                m_rExport.bRTFFlySyntax = true;
  8.1435 +                m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
  8.1436 +                m_rExport.bRTFFlySyntax = false;
  8.1437 +                m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
  8.1438 +                m_rExport.OutputFormat( rFrame.GetFrmFmt(), false, false, true );
  8.1439 +                m_aRunText.append('}');
  8.1440 +                m_rExport.mpParentFrame = NULL;
  8.1441 +            }
  8.1442 +
  8.1443 +            if ( pGrfNode )
  8.1444 +                FlyFrameGraphic( *pGrfNode, rFrame.GetLayoutSize() );
  8.1445 +            break;
  8.1446 +        case sw::Frame::eDrawing:
  8.1447 +            {
  8.1448 +                const SdrObject* pSdrObj = rFrame.GetFrmFmt().FindRealSdrObject();
  8.1449 +                if ( pSdrObj )
  8.1450 +                {
  8.1451 +                    bool bSwapInPage = false;
  8.1452 +                    if ( !pSdrObj->GetPage() )
  8.1453 +                    {
  8.1454 +                        if ( SdrModel* pModel = m_rExport.pDoc->GetDrawModel() )
  8.1455 +                        {
  8.1456 +                            if ( SdrPage *pPage = pModel->GetPage( 0 ) )
  8.1457 +                            {
  8.1458 +                                bSwapInPage = true;
  8.1459 +                                const_cast< SdrObject* >( pSdrObj )->SetPage( pPage );
  8.1460 +                            }
  8.1461 +                        }
  8.1462 +                    }
  8.1463 +
  8.1464 +                    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_FIELD "{");
  8.1465 +                    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
  8.1466 +                    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLDINST);
  8.1467 +                    m_aRunText.append(" SHAPE ");
  8.1468 +                    m_aRunText.append("}" "{" OOO_STRING_SVTOOLS_RTF_FLDRSLT);
  8.1469 +
  8.1470 +                    m_rExport.SdrExporter().AddSdrObject( *pSdrObj );
  8.1471 +
  8.1472 +                    m_aRunText.append('}');
  8.1473 +                    m_aRunText.append('}');
  8.1474 +
  8.1475 +                    if ( bSwapInPage )
  8.1476 +                        const_cast< SdrObject* >( pSdrObj )->SetPage( 0 );
  8.1477 +                }
  8.1478 +            }
  8.1479 +            break;
  8.1480 +        case sw::Frame::eFormControl:
  8.1481 +            {
  8.1482 +                const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
  8.1483 +                const SdrObject *pObject = rFrmFmt.FindRealSdrObject();
  8.1484 +
  8.1485 +                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_FIELD);
  8.1486 +                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FLDINST);
  8.1487 +
  8.1488 +                if (pObject && pObject->GetObjInventor() == FmFormInventor)
  8.1489 +                {
  8.1490 +                    if (SdrUnoObj *pFormObj = PTR_CAST(SdrUnoObj,pObject))
  8.1491 +                    {
  8.1492 +                        uno::Reference< awt::XControlModel > xControlModel =
  8.1493 +                            pFormObj->GetUnoControlModel();
  8.1494 +                        uno::Reference< lang::XServiceInfo > xInfo(xControlModel, uno::UNO_QUERY);
  8.1495 +                        uno::Reference<beans::XPropertySet> xPropSet(xControlModel, uno::UNO_QUERY);
  8.1496 +                        uno::Reference<beans::XPropertySetInfo> xPropSetInfo = xPropSet->getPropertySetInfo();
  8.1497 +                        OUString sName;
  8.1498 +                        if (xInfo->supportsService(C2U("com.sun.star.form.component.CheckBox")))
  8.1499 +                        {
  8.1500 +
  8.1501 +                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMCHECKBOX)), m_rExport.eCurrentEncoding));
  8.1502 +                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
  8.1503 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFTYPE "1"); // 1 = checkbox
  8.1504 +                            // checkbox size in half points, this seems to be always 20, see WW8Export::DoCheckBox()
  8.1505 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFHPS "20");
  8.1506 +
  8.1507 +                            OUString aStr;
  8.1508 +                            sName = C2U("Name");
  8.1509 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1510 +                            {
  8.1511 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1512 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
  8.1513 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1514 +                                m_aRun.append('}');
  8.1515 +                            }
  8.1516 +
  8.1517 +                            sName = C2U("HelpText");
  8.1518 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1519 +                            {
  8.1520 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1521 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
  8.1522 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
  8.1523 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1524 +                                m_aRun.append('}');
  8.1525 +                            }
  8.1526 +
  8.1527 +                            sName = C2U("HelpF1Text");
  8.1528 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1529 +                            {
  8.1530 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1531 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
  8.1532 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
  8.1533 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1534 +                                m_aRun.append('}');
  8.1535 +                            }
  8.1536 +
  8.1537 +                            sal_Int16 nTemp = 0;
  8.1538 +                            xPropSet->getPropertyValue(C2U("DefaultState")) >>= nTemp;
  8.1539 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
  8.1540 +                            m_aRun.append((sal_Int32)nTemp);
  8.1541 +                            xPropSet->getPropertyValue(C2U("State")) >>= nTemp;
  8.1542 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFRES);
  8.1543 +                            m_aRun.append((sal_Int32)nTemp);
  8.1544 +
  8.1545 +                            m_aRun.append("}}");
  8.1546 +
  8.1547 +                            // field result is empty, ffres already contains the form result
  8.1548 +                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
  8.1549 +                        }
  8.1550 +                        else if (xInfo->supportsService(C2U("com.sun.star.form.component.TextField")))
  8.1551 +                        {
  8.1552 +                            OStringBuffer aBuf;
  8.1553 +                            OString aStr;
  8.1554 +                            OUString aTmp;
  8.1555 +                            const sal_Char* pStr;
  8.1556 +
  8.1557 +                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMTEXT)), m_rExport.eCurrentEncoding));
  8.1558 +                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_DATAFIELD " ");
  8.1559 +                            for (int i = 0; i < 8; i++) aBuf.append((sal_Char)0x00);
  8.1560 +                            xPropSet->getPropertyValue(C2U("Name")) >>= aTmp;
  8.1561 +                            aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
  8.1562 +                            aBuf.append((sal_Char)aStr.getLength());
  8.1563 +                            aBuf.append(aStr);
  8.1564 +                            aBuf.append((sal_Char)0x00);
  8.1565 +                            xPropSet->getPropertyValue(C2U("DefaultText")) >>= aTmp;
  8.1566 +                            aStr = OUStringToOString(aTmp, m_rExport.eCurrentEncoding);
  8.1567 +                            aBuf.append((sal_Char)aStr.getLength());
  8.1568 +                            aBuf.append(aStr);
  8.1569 +                            for (int i = 0; i < 11; i++) aBuf.append((sal_Char)0x00);
  8.1570 +                            aStr = aBuf.makeStringAndClear();
  8.1571 +                            pStr = aStr.getStr();
  8.1572 +                            for (int i = 0; i < aStr.getLength(); i++, pStr++)
  8.1573 +                                m_aRun.append(m_rExport.OutHex(*pStr, 2));
  8.1574 +                            m_aRun.append('}');
  8.1575 +                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
  8.1576 +                            xPropSet->getPropertyValue(C2U("Text")) >>= aTmp;
  8.1577 +                            m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
  8.1578 +                            m_aRun.append('}');
  8.1579 +                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
  8.1580 +                            sName = C2U("HelpText");
  8.1581 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1582 +                            {
  8.1583 +                                xPropSet->getPropertyValue(sName) >>= aTmp;
  8.1584 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
  8.1585 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
  8.1586 +                                m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
  8.1587 +                                m_aRun.append('}');
  8.1588 +                            }
  8.1589 +
  8.1590 +                            sName = C2U("HelpF1Text");
  8.1591 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1592 +                            {
  8.1593 +                                xPropSet->getPropertyValue(sName) >>= aTmp;
  8.1594 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
  8.1595 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
  8.1596 +                                m_aRun.append(OUStringToOString(aTmp, m_rExport.eCurrentEncoding));
  8.1597 +                                m_aRun.append('}');
  8.1598 +                            }
  8.1599 +                            m_aRun.append("}");
  8.1600 +                        }
  8.1601 +                        else if (xInfo->supportsService(C2U("com.sun.star.form.component.ListBox")))
  8.1602 +                        {
  8.1603 +                            OUString aStr;
  8.1604 +                            uno::Sequence<sal_Int16> aIntSeq;
  8.1605 +                            uno::Sequence<OUString> aStrSeq;
  8.1606 +
  8.1607 +                            m_aRun.append(OUStringToOString(OUString(FieldString(ww::eFORMDROPDOWN)), m_rExport.eCurrentEncoding));
  8.1608 +                            m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FORMFIELD "{");
  8.1609 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFTYPE "2"); // 2 = list
  8.1610 +
  8.1611 +                            xPropSet->getPropertyValue(C2U("DefaultSelection")) >>= aIntSeq;
  8.1612 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFDEFRES);
  8.1613 +                            // a dropdown list can have only one 'selected item by default'
  8.1614 +                            m_aRun.append((sal_Int32)aIntSeq[0]);
  8.1615 +
  8.1616 +                            xPropSet->getPropertyValue(C2U("SelectedItems")) >>= aIntSeq;
  8.1617 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFRES);
  8.1618 +                            // a dropdown list can have only one 'currently selected item'
  8.1619 +                            m_aRun.append((sal_Int32)aIntSeq[0]);
  8.1620 +
  8.1621 +                            sName = C2U("Name");
  8.1622 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1623 +                            {
  8.1624 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1625 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFNAME " ");
  8.1626 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1627 +                                m_aRun.append('}');
  8.1628 +                            }
  8.1629 +
  8.1630 +                            sName = C2U("HelpText");
  8.1631 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1632 +                            {
  8.1633 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1634 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNHELP);
  8.1635 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFHELPTEXT " ");
  8.1636 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1637 +                                m_aRun.append('}');
  8.1638 +                            }
  8.1639 +
  8.1640 +                            sName = C2U("HelpF1Text");
  8.1641 +                            if (xPropSetInfo->hasPropertyByName(sName))
  8.1642 +                            {
  8.1643 +                                xPropSet->getPropertyValue(sName) >>= aStr;
  8.1644 +                                m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFOWNSTAT);
  8.1645 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFSTATTEXT " ");
  8.1646 +                                m_aRun.append(OUStringToOString(aStr, m_rExport.eCurrentEncoding));
  8.1647 +                                m_aRun.append('}');
  8.1648 +                            }
  8.1649 +
  8.1650 +                            m_aRun.append(OOO_STRING_SVTOOLS_RTF_FFHASLISTBOX);
  8.1651 +
  8.1652 +                            xPropSet->getPropertyValue(C2U("StringItemList")) >>= aStrSeq;
  8.1653 +                            sal_uInt32 nListItems = aStrSeq.getLength();
  8.1654 +                            for (sal_uInt32 i = 0; i < nListItems; i++)
  8.1655 +                                m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FFL " ")
  8.1656 +                                    .append(OUStringToOString(aStrSeq[i], m_rExport.eCurrentEncoding)).append('}');
  8.1657 +
  8.1658 +                            m_aRun.append("}}");
  8.1659 +
  8.1660 +                            // field result is empty, ffres already contains the form result
  8.1661 +                            m_aRun.append("}{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
  8.1662 +                        }
  8.1663 +                        else
  8.1664 +                            OSL_TRACE("%s unhandled form control: '%s'", __PRETTY_FUNCTION__,
  8.1665 +                                    OUStringToOString(xInfo->getImplementationName(), m_rExport.eCurrentEncoding).getStr());
  8.1666 +                        m_aRun.append('}');
  8.1667 +                    }
  8.1668 +                }
  8.1669 +
  8.1670 +                m_aRun.append('}');
  8.1671 +            }
  8.1672 +            break;
  8.1673 +        case sw::Frame::eOle:
  8.1674 +            {
  8.1675 +                const SwFrmFmt &rFrmFmt = rFrame.GetFrmFmt();
  8.1676 +                const SdrObject *pSdrObj = rFrmFmt.FindRealSdrObject();
  8.1677 +                if ( pSdrObj )
  8.1678 +                {
  8.1679 +                    SwNodeIndex aIdx(*rFrmFmt.GetCntnt().GetCntntIdx(), 1);
  8.1680 +                    SwOLENode& rOLENd = *aIdx.GetNode().GetOLENode();
  8.1681 +                    FlyFrameOLE(rOLENd, rFrame.GetLayoutSize());
  8.1682 +                }
  8.1683 +            }
  8.1684 +            break;
  8.1685 +        default:
  8.1686 +            OSL_TRACE("%s: unknown type (%d)", __PRETTY_FUNCTION__, rFrame.GetWriterType());
  8.1687 +            break;
  8.1688 +    }
  8.1689 +}
  8.1690 +
  8.1691 +void RtfAttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
  8.1692 +{
  8.1693 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1694 +
  8.1695 +    switch ( rCaseMap.GetValue() )
  8.1696 +    {
  8.1697 +        case SVX_CASEMAP_KAPITAELCHEN:
  8.1698 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
  8.1699 +            break;
  8.1700 +        case SVX_CASEMAP_VERSALIEN:
  8.1701 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
  8.1702 +            break;
  8.1703 +        default: // Something that rtf does not support
  8.1704 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SCAPS);
  8.1705 +            m_aStyles.append((sal_Int32)0);
  8.1706 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CAPS);
  8.1707 +            m_aStyles.append((sal_Int32)0);
  8.1708 +            break;
  8.1709 +    }
  8.1710 +}
  8.1711 +
  8.1712 +void RtfAttributeOutput::CharColor( const SvxColorItem& rColor )
  8.1713 +{
  8.1714 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1715 +
  8.1716 +    const Color aColor( rColor.GetValue() );
  8.1717 +
  8.1718 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CF);
  8.1719 +    m_aStyles.append( (sal_Int32)m_rExport.GetColor( aColor ));
  8.1720 +}
  8.1721 +
  8.1722 +void RtfAttributeOutput::CharContour( const SvxContourItem& rContour )
  8.1723 +{
  8.1724 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1725 +
  8.1726 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_OUTL);
  8.1727 +    if ( !rContour.GetValue() )
  8.1728 +        m_aStyles.append((sal_Int32)0);
  8.1729 +}
  8.1730 +
  8.1731 +void RtfAttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossedOut )
  8.1732 +{
  8.1733 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1734 +
  8.1735 +    switch ( rCrossedOut.GetStrikeout() )
  8.1736 +    {
  8.1737 +        case STRIKEOUT_NONE:
  8.1738 +            if (!m_bStrikeDouble)
  8.1739 +                m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
  8.1740 +            else
  8.1741 +                m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
  8.1742 +            m_aStyles.append((sal_Int32)0);
  8.1743 +            break;
  8.1744 +        case STRIKEOUT_DOUBLE:
  8.1745 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKED);
  8.1746 +            m_aStyles.append((sal_Int32)1);
  8.1747 +            break;
  8.1748 +        default:
  8.1749 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_STRIKE);
  8.1750 +            break;
  8.1751 +    }
  8.1752 +}
  8.1753 +
  8.1754 +void RtfAttributeOutput::CharEscapement( const SvxEscapementItem& rEsc )
  8.1755 +{
  8.1756 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1757 +
  8.1758 +    const char * pUpDn;
  8.1759 +
  8.1760 +    SwTwips nH = ((SvxFontHeightItem&)m_rExport.GetItem( RES_CHRATR_FONTSIZE )).GetHeight();
  8.1761 +
  8.1762 +    if( 0 < rEsc.GetEsc() )
  8.1763 +        pUpDn = OOO_STRING_SVTOOLS_RTF_UP;
  8.1764 +    else if( 0 > rEsc.GetEsc() )
  8.1765 +    {
  8.1766 +        pUpDn = OOO_STRING_SVTOOLS_RTF_DN;
  8.1767 +        nH = -nH;
  8.1768 +    }
  8.1769 +    else
  8.1770 +        return;
  8.1771 +
  8.1772 +    short nEsc = rEsc.GetEsc();
  8.1773 +    short nProp = rEsc.GetProp() * 100;
  8.1774 +    if( DFLT_ESC_AUTO_SUPER == nEsc )
  8.1775 +    {
  8.1776 +        nEsc = 100 - rEsc.GetProp();
  8.1777 +        ++nProp;
  8.1778 +    }
  8.1779 +    else if( DFLT_ESC_AUTO_SUB == nEsc )
  8.1780 +    {
  8.1781 +        nEsc = - 100 + rEsc.GetProp();
  8.1782 +        ++nProp;
  8.1783 +    }
  8.1784 +
  8.1785 +    m_aStyles.append('{');
  8.1786 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
  8.1787 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_UPDNPROP);
  8.1788 +    m_aStyles.append( (sal_Int32)nProp );
  8.1789 +    m_aStyles.append('}');
  8.1790 +    m_aStyles.append(pUpDn);
  8.1791 +
  8.1792 +    /*
  8.1793 +     * Calculate the act. FontSize and the percentage of the displacement;
  8.1794 +     * RTF file expects half points, while internally it's in twips.
  8.1795 +     * Formally :            (FontSize * 1/20 ) pts         x * 2
  8.1796 +     *                    -----------------------  = ------------
  8.1797 +     *                      100%                       Escapement
  8.1798 +     */
  8.1799 +
  8.1800 +    m_aStyles.append( (sal_Int32) ( (long( nEsc ) * nH) + 500L ) / 1000L );
  8.1801 +    // 500L to round !!
  8.1802 +}
  8.1803 +
  8.1804 +void RtfAttributeOutput::CharFont( const SvxFontItem& rFont)
  8.1805 +{
  8.1806 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1807 +
  8.1808 +    m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LOCH);
  8.1809 +    m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_F);
  8.1810 +    m_aStylesEnd.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
  8.1811 +    m_rExport.eCurrentEncoding = rtl_getTextEncodingFromWindowsCharset(sw::ms::rtl_TextEncodingToWinCharset(rFont.GetCharSet()));
  8.1812 +}
  8.1813 +
  8.1814 +void RtfAttributeOutput::CharFontSize( const SvxFontHeightItem& rFontSize)
  8.1815 +{
  8.1816 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1817 +
  8.1818 +    switch ( rFontSize.Which() )
  8.1819 +    {
  8.1820 +        case RES_CHRATR_FONTSIZE:
  8.1821 +            m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_FS);
  8.1822 +            m_aStylesEnd.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
  8.1823 +            break;
  8.1824 +        case RES_CHRATR_CJK_FONTSIZE:
  8.1825 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FS);
  8.1826 +            m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
  8.1827 +            break;
  8.1828 +        case RES_CHRATR_CTL_FONTSIZE:
  8.1829 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AFS);
  8.1830 +            m_aStyles.append((sal_Int32)(rFontSize.GetHeight() / 10 ));
  8.1831 +            break;
  8.1832 +    }
  8.1833 +}
  8.1834 +
  8.1835 +void RtfAttributeOutput::CharKerning( const SvxKerningItem& rKerning )
  8.1836 +{
  8.1837 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1838 +
  8.1839 +    // in quater points then in twips
  8.1840 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPND);
  8.1841 +    m_aStyles.append((sal_Int32)(rKerning.GetValue() / 5));
  8.1842 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_EXPNDTW);
  8.1843 +    m_aStyles.append((sal_Int32)(rKerning.GetValue()));
  8.1844 +}
  8.1845 +
  8.1846 +void RtfAttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
  8.1847 +{
  8.1848 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1849 +
  8.1850 +    switch (rLanguage.Which())
  8.1851 +    {
  8.1852 +        case RES_CHRATR_LANGUAGE:
  8.1853 +            m_aStylesEnd.append(OOO_STRING_SVTOOLS_RTF_LANG);
  8.1854 +            m_aStylesEnd.append((sal_Int32)rLanguage.GetLanguage());
  8.1855 +            break;
  8.1856 +        case RES_CHRATR_CJK_LANGUAGE:
  8.1857 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANGFE);
  8.1858 +            m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
  8.1859 +            break;
  8.1860 +        case RES_CHRATR_CTL_LANGUAGE:
  8.1861 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LANG);
  8.1862 +            m_aStyles.append((sal_Int32)rLanguage.GetLanguage());
  8.1863 +            break;
  8.1864 +    }
  8.1865 +}
  8.1866 +
  8.1867 +void RtfAttributeOutput::CharPosture( const SvxPostureItem& rPosture )
  8.1868 +{
  8.1869 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1870 +
  8.1871 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
  8.1872 +    if ( rPosture.GetPosture() == ITALIC_NONE )
  8.1873 +        m_aStyles.append((sal_Int32)0);
  8.1874 +}
  8.1875 +
  8.1876 +void RtfAttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
  8.1877 +{
  8.1878 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1879 +
  8.1880 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SHAD);
  8.1881 +    if ( !rShadow.GetValue() )
  8.1882 +        m_aStyles.append((sal_Int32)0);
  8.1883 +}
  8.1884 +
  8.1885 +void RtfAttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
  8.1886 +{
  8.1887 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1888 +
  8.1889 +    const char* pStr = 0;
  8.1890 +    const SfxPoolItem* pItem = m_rExport.HasItem( RES_CHRATR_WORDLINEMODE );
  8.1891 +    bool bWord = false;
  8.1892 +    if (pItem)
  8.1893 +        bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false;
  8.1894 +    switch(rUnderline.GetLineStyle() )
  8.1895 +    {
  8.1896 +        case UNDERLINE_SINGLE:
  8.1897 +            pStr = bWord ? OOO_STRING_SVTOOLS_RTF_ULW : OOO_STRING_SVTOOLS_RTF_UL;
  8.1898 +            break;
  8.1899 +        case UNDERLINE_DOUBLE:
  8.1900 +            pStr = OOO_STRING_SVTOOLS_RTF_ULDB;
  8.1901 +            break;
  8.1902 +        case UNDERLINE_NONE:
  8.1903 +            pStr = OOO_STRING_SVTOOLS_RTF_ULNONE;
  8.1904 +            break;
  8.1905 +        case UNDERLINE_DOTTED:
  8.1906 +            pStr = OOO_STRING_SVTOOLS_RTF_ULD;
  8.1907 +            break;
  8.1908 +        case UNDERLINE_DASH:
  8.1909 +            pStr = OOO_STRING_SVTOOLS_RTF_ULDASH;
  8.1910 +            break;
  8.1911 +        case UNDERLINE_DASHDOT:
  8.1912 +            pStr = OOO_STRING_SVTOOLS_RTF_ULDASHD;
  8.1913 +            break;
  8.1914 +        case UNDERLINE_DASHDOTDOT:
  8.1915 +            pStr = OOO_STRING_SVTOOLS_RTF_ULDASHDD;
  8.1916 +            break;
  8.1917 +        case UNDERLINE_BOLD:
  8.1918 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTH;
  8.1919 +            break;
  8.1920 +        case UNDERLINE_WAVE:
  8.1921 +            pStr = OOO_STRING_SVTOOLS_RTF_ULWAVE;
  8.1922 +            break;
  8.1923 +        case UNDERLINE_BOLDDOTTED:
  8.1924 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTHD;
  8.1925 +            break;
  8.1926 +        case UNDERLINE_BOLDDASH:
  8.1927 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASH;
  8.1928 +            break;
  8.1929 +        case UNDERLINE_LONGDASH:
  8.1930 +            pStr = OOO_STRING_SVTOOLS_RTF_ULLDASH;
  8.1931 +            break;
  8.1932 +        case UNDERLINE_BOLDLONGDASH:
  8.1933 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTHLDASH;
  8.1934 +            break;
  8.1935 +        case UNDERLINE_BOLDDASHDOT:
  8.1936 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHD;
  8.1937 +            break;
  8.1938 +        case UNDERLINE_BOLDDASHDOTDOT:
  8.1939 +            pStr = OOO_STRING_SVTOOLS_RTF_ULTHDASHDD;
  8.1940 +            break;
  8.1941 +        case UNDERLINE_BOLDWAVE:
  8.1942 +            pStr = OOO_STRING_SVTOOLS_RTF_ULHWAVE;
  8.1943 +            break;
  8.1944 +        case UNDERLINE_DOUBLEWAVE:
  8.1945 +            pStr = OOO_STRING_SVTOOLS_RTF_ULULDBWAVE;
  8.1946 +            break;
  8.1947 +        default:
  8.1948 +            break;
  8.1949 +    }
  8.1950 +
  8.1951 +    if( pStr )
  8.1952 +    {
  8.1953 +        m_aStyles.append(pStr);
  8.1954 +        // NEEDSWORK looks like here rUnderline.GetColor() is always black,
  8.1955 +        // even if the color in the odt is for example green...
  8.1956 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ULC);
  8.1957 +        m_aStyles.append( (sal_Int32)m_rExport.GetColor(rUnderline.GetColor()) );
  8.1958 +    }
  8.1959 +}
  8.1960 +
  8.1961 +void RtfAttributeOutput::CharWeight( const SvxWeightItem& rWeight )
  8.1962 +{
  8.1963 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1964 +
  8.1965 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
  8.1966 +    if ( rWeight.GetWeight() != WEIGHT_BOLD )
  8.1967 +        m_aStyles.append((sal_Int32)0);
  8.1968 +}
  8.1969 +
  8.1970 +void RtfAttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern)
  8.1971 +{
  8.1972 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1973 +
  8.1974 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KERNING);
  8.1975 +    m_aStyles.append((sal_Int32) (rAutoKern.GetValue() ? 1 : 0));
  8.1976 +}
  8.1977 +
  8.1978 +void RtfAttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
  8.1979 +{
  8.1980 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1981 +
  8.1982 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ANIMTEXT);
  8.1983 +    m_aStyles.append((sal_Int32) (rBlink.GetValue() ? 2 : 0));
  8.1984 +}
  8.1985 +
  8.1986 +void RtfAttributeOutput::CharBackground( const SvxBrushItem& rBrush )
  8.1987 +{
  8.1988 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.1989 +
  8.1990 +    if( !rBrush.GetColor().GetTransparency() )
  8.1991 +    {
  8.1992 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
  8.1993 +        m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
  8.1994 +    }
  8.1995 +}
  8.1996 +
  8.1997 +void RtfAttributeOutput::CharFontCJK( const SvxFontItem& rFont )
  8.1998 +{
  8.1999 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2000 +
  8.2001 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HICH);
  8.2002 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
  8.2003 +    m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
  8.2004 +}
  8.2005 +
  8.2006 +void RtfAttributeOutput::CharFontSizeCJK( const SvxFontHeightItem& rFontSize )
  8.2007 +{
  8.2008 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2009 +
  8.2010 +    CharFontSize( rFontSize );
  8.2011 +}
  8.2012 +
  8.2013 +void RtfAttributeOutput::CharLanguageCJK( const SvxLanguageItem& rLanguageItem )
  8.2014 +{
  8.2015 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2016 +
  8.2017 +    CharLanguage( rLanguageItem );
  8.2018 +}
  8.2019 +
  8.2020 +void RtfAttributeOutput::CharPostureCJK( const SvxPostureItem& rPosture )
  8.2021 +{
  8.2022 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2023 +
  8.2024 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_I);
  8.2025 +    if ( rPosture.GetPosture() == ITALIC_NONE )
  8.2026 +        m_aStyles.append((sal_Int32)0);
  8.2027 +}
  8.2028 +
  8.2029 +void RtfAttributeOutput::CharWeightCJK( const SvxWeightItem& rWeight )
  8.2030 +{
  8.2031 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2032 +
  8.2033 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_B);
  8.2034 +    if ( rWeight.GetWeight() != WEIGHT_BOLD )
  8.2035 +        m_aStyles.append((sal_Int32)0);
  8.2036 +}
  8.2037 +
  8.2038 +void RtfAttributeOutput::CharFontCTL( const SvxFontItem& rFont )
  8.2039 +{
  8.2040 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2041 +
  8.2042 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_DBCH);
  8.2043 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AF);
  8.2044 +    m_aStyles.append((sal_Int32)m_rExport.maFontHelper.GetId(rFont));
  8.2045 +}
  8.2046 +
  8.2047 +void RtfAttributeOutput::CharFontSizeCTL( const SvxFontHeightItem& rFontSize )
  8.2048 +{
  8.2049 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2050 +
  8.2051 +    CharFontSize( rFontSize );
  8.2052 +}
  8.2053 +
  8.2054 +void RtfAttributeOutput::CharLanguageCTL( const SvxLanguageItem& rLanguageItem )
  8.2055 +{
  8.2056 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2057 +
  8.2058 +    CharLanguage( rLanguageItem );
  8.2059 +}
  8.2060 +
  8.2061 +void RtfAttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture)
  8.2062 +{
  8.2063 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2064 +
  8.2065 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AI);
  8.2066 +    if ( rPosture.GetPosture() == ITALIC_NONE )
  8.2067 +        m_aStyles.append((sal_Int32)0);
  8.2068 +}
  8.2069 +
  8.2070 +void RtfAttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
  8.2071 +{
  8.2072 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2073 +
  8.2074 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_AB);
  8.2075 +    if ( rWeight.GetWeight() != WEIGHT_BOLD )
  8.2076 +        m_aStyles.append((sal_Int32)0);
  8.2077 +}
  8.2078 +
  8.2079 +void RtfAttributeOutput::CharRotate( const SvxCharRotateItem& rRotate)
  8.2080 +{
  8.2081 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2082 +
  8.2083 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HORZVERT);
  8.2084 +    m_aStyles.append((sal_Int32)(rRotate.IsFitToLine() ? 1 : 0));
  8.2085 +}
  8.2086 +
  8.2087 +void RtfAttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
  8.2088 +{
  8.2089 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2090 +
  8.2091 +    const sal_Char* pStr;
  8.2092 +    switch( rEmphasisMark.GetEmphasisMark())
  8.2093 +    {
  8.2094 +        case EMPHASISMARK_NONE:         pStr = OOO_STRING_SVTOOLS_RTF_ACCNONE;  break;
  8.2095 +        case EMPHASISMARK_SIDE_DOTS:    pStr = OOO_STRING_SVTOOLS_RTF_ACCCOMMA; break;
  8.2096 +        default:                        pStr = OOO_STRING_SVTOOLS_RTF_ACCDOT;   break;
  8.2097 +    }
  8.2098 +    m_aStyles.append(pStr);
  8.2099 +}
  8.2100 +
  8.2101 +void RtfAttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
  8.2102 +{
  8.2103 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2104 +
  8.2105 +    if( rTwoLines.GetValue() )
  8.2106 +    {
  8.2107 +        sal_Unicode cStart = rTwoLines.GetStartBracket();
  8.2108 +        sal_Unicode cEnd =   rTwoLines.GetEndBracket();
  8.2109 +
  8.2110 +        USHORT nType;
  8.2111 +        if( !cStart && !cEnd )
  8.2112 +            nType = 0;
  8.2113 +        else if( '{' == cStart || '}' == cEnd )
  8.2114 +            nType = 4;
  8.2115 +        else if( '<' == cStart || '>' == cEnd )
  8.2116 +            nType = 3;
  8.2117 +        else if( '[' == cStart || ']' == cEnd )
  8.2118 +            nType = 2;
  8.2119 +        else                            // all other kind of brackets
  8.2120 +            nType = 1;
  8.2121 +
  8.2122 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TWOINONE);
  8.2123 +        m_aStyles.append((sal_Int32)nType);
  8.2124 +    }
  8.2125 +}
  8.2126 +
  8.2127 +void RtfAttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
  8.2128 +{
  8.2129 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2130 +
  8.2131 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHARSCALEX);
  8.2132 +    m_aStyles.append((sal_Int32)rScaleWidth.GetValue());
  8.2133 +}
  8.2134 +
  8.2135 +void RtfAttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
  8.2136 +{
  8.2137 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2138 +
  8.2139 +    const sal_Char* pStr;
  8.2140 +    switch (rRelief.GetValue())
  8.2141 +    {
  8.2142 +        case RELIEF_EMBOSSED:
  8.2143 +            pStr = OOO_STRING_SVTOOLS_RTF_EMBO;
  8.2144 +            break;
  8.2145 +        case RELIEF_ENGRAVED:
  8.2146 +            pStr = OOO_STRING_SVTOOLS_RTF_IMPR;
  8.2147 +            break;
  8.2148 +        default:
  8.2149 +            pStr = 0;
  8.2150 +            break;
  8.2151 +    }
  8.2152 +
  8.2153 +    if (pStr)
  8.2154 +        m_aStyles.append(pStr);
  8.2155 +}
  8.2156 +
  8.2157 +void RtfAttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
  8.2158 +{
  8.2159 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2160 +
  8.2161 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_V);
  8.2162 +    if ( !rHidden.GetValue() )
  8.2163 +        m_aStyles.append((sal_Int32)0);
  8.2164 +}
  8.2165 +
  8.2166 +void RtfAttributeOutput::TextINetFormat( const SwFmtINetFmt& rURL )
  8.2167 +{
  8.2168 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2169 +
  8.2170 +    if( rURL.GetValue().Len() )
  8.2171 +    {
  8.2172 +        const SwCharFmt* pFmt;
  8.2173 +        const SwTxtINetFmt* pTxtAtr = rURL.GetTxtINetFmt();
  8.2174 +
  8.2175 +        m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_FLDRSLT " ");
  8.2176 +        if( pTxtAtr && 0 != ( pFmt = pTxtAtr->GetCharFmt() ))
  8.2177 +        {
  8.2178 +            USHORT nStyle = m_rExport.GetId( *pFmt );
  8.2179 +            OString* pString = m_rExport.GetStyle(nStyle);
  8.2180 +            if (pString)
  8.2181 +                m_aStyles.append(*pString);
  8.2182 +        }
  8.2183 +    }
  8.2184 +}
  8.2185 +
  8.2186 +void RtfAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
  8.2187 +{
  8.2188 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2189 +
  8.2190 +    USHORT nStyle = m_rExport.GetId( *rCharFmt.GetCharFmt() );
  8.2191 +    OString* pString = m_rExport.GetStyle(nStyle);
  8.2192 +    if (pString)
  8.2193 +        m_aStyles.append(*pString);
  8.2194 +}
  8.2195 +
  8.2196 +void RtfAttributeOutput::WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote)
  8.2197 +{
  8.2198 +    if (!rFootnote.GetNumStr().Len())
  8.2199 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_CHFTN);
  8.2200 +    else
  8.2201 +        m_aRun.append(m_rExport.OutString(rFootnote.GetNumStr(), m_rExport.eCurrentEncoding));
  8.2202 +}
  8.2203 +
  8.2204 +void RtfAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
  8.2205 +{
  8.2206 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
  8.2207 +
  8.2208 +    m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_SUPER " ");
  8.2209 +    WriteTextFootnoteNumStr(rFootnote);
  8.2210 +    m_aRun.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_FOOTNOTE);
  8.2211 +    if( rFootnote.IsEndNote() )
  8.2212 +        m_aRun.append(OOO_STRING_SVTOOLS_RTF_FTNALT);
  8.2213 +    m_aRun.append(' ');
  8.2214 +    WriteTextFootnoteNumStr(rFootnote);
  8.2215 +
  8.2216 +    /*
  8.2217 +     * The footnote contains a whole paragraph, so we have to:
  8.2218 +     * 1) Reset, then later restore the contents of our run buffer.
  8.2219 +     * 2) Buffer the output of the whole paragraph, as we do so for section headers already.
  8.2220 +     */
  8.2221 +    const SwNodeIndex* pIndex = rFootnote.GetTxtFtn()->GetStartNode();
  8.2222 +    OStringBuffer aRun = m_aRun;
  8.2223 +    m_aRun.setLength(0);
  8.2224 +    m_bBufferSectionHeaders = true;
  8.2225 +    m_rExport.WriteSpecialText( pIndex->GetIndex() + 1,
  8.2226 +            pIndex->GetNode().EndOfSectionIndex(),
  8.2227 +            !rFootnote.IsEndNote() ? TXT_FTN : TXT_EDN);
  8.2228 +    m_bBufferSectionHeaders = false;
  8.2229 +    m_aRun = aRun;
  8.2230 +    m_aRun.append(m_aSectionHeaders.makeStringAndClear());
  8.2231 +
  8.2232 +    m_aRun.append("}");
  8.2233 +    m_aRun.append("}");
  8.2234 +
  8.2235 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
  8.2236 +}
  8.2237 +
  8.2238 +void RtfAttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
  8.2239 +{
  8.2240 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2241 +
  8.2242 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SL);
  8.2243 +    m_aStyles.append((sal_Int32)nSpace);
  8.2244 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SLMULT);
  8.2245 +    m_aStyles.append((sal_Int32)nMulti);
  8.2246 +
  8.2247 +}
  8.2248 +
  8.2249 +void RtfAttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
  8.2250 +{
  8.2251 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2252 +
  8.2253 +    switch ( rAdjust.GetAdjust() )
  8.2254 +    {
  8.2255 +        case SVX_ADJUST_LEFT:
  8.2256 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QL);
  8.2257 +            break;
  8.2258 +        case SVX_ADJUST_RIGHT:
  8.2259 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QR);
  8.2260 +            break;
  8.2261 +        case SVX_ADJUST_BLOCKLINE:
  8.2262 +        case SVX_ADJUST_BLOCK:
  8.2263 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QJ);
  8.2264 +            break;
  8.2265 +        case SVX_ADJUST_CENTER:
  8.2266 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_QC);
  8.2267 +            break;
  8.2268 +        default:
  8.2269 +            break;
  8.2270 +    }
  8.2271 +}
  8.2272 +
  8.2273 +void RtfAttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
  8.2274 +{
  8.2275 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2276 +
  8.2277 +    if( !rSplit.GetValue() )
  8.2278 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEP);
  8.2279 +}
  8.2280 +
  8.2281 +void RtfAttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
  8.2282 +{
  8.2283 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2284 +
  8.2285 +    if (rWidows.GetValue())
  8.2286 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_WIDCTLPAR);
  8.2287 +    else
  8.2288 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOWIDCTLPAR);
  8.2289 +}
  8.2290 +
  8.2291 +void RtfAttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStop )
  8.2292 +{
  8.2293 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2294 +
  8.2295 +    long nOffset = ((SvxLRSpaceItem&)m_rExport.GetItem( RES_LR_SPACE )).GetTxtLeft();
  8.2296 +    for( USHORT n = 0; n < rTabStop.Count(); n++ )
  8.2297 +    {
  8.2298 +        const SvxTabStop & rTS = rTabStop[ n ];
  8.2299 +        if( SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment() )
  8.2300 +        {
  8.2301 +            const char* pFill = 0;
  8.2302 +            switch( rTS.GetFill() )
  8.2303 +            {
  8.2304 +                case cDfltFillChar:
  8.2305 +                    break;
  8.2306 +
  8.2307 +                case '.':    pFill = OOO_STRING_SVTOOLS_RTF_TLDOT;    break;
  8.2308 +                case '_':    pFill = OOO_STRING_SVTOOLS_RTF_TLUL;    break;
  8.2309 +                case '-':    pFill = OOO_STRING_SVTOOLS_RTF_TLTH;    break;
  8.2310 +                case '=':    pFill = OOO_STRING_SVTOOLS_RTF_TLEQ;    break;
  8.2311 +                default:
  8.2312 +                        break;
  8.2313 +            }
  8.2314 +            if( pFill )
  8.2315 +                m_aStyles.append(pFill);
  8.2316 +
  8.2317 +            const sal_Char* pAdjStr = 0;
  8.2318 +            switch (rTS.GetAdjustment())
  8.2319 +            {
  8.2320 +                case SVX_TAB_ADJUST_RIGHT:
  8.2321 +                    pAdjStr = OOO_STRING_SVTOOLS_RTF_TQR;
  8.2322 +                    break;
  8.2323 +                case SVX_TAB_ADJUST_DECIMAL:
  8.2324 +                    pAdjStr = OOO_STRING_SVTOOLS_RTF_TQDEC;
  8.2325 +                    break;
  8.2326 +                case SVX_TAB_ADJUST_CENTER:
  8.2327 +                    pAdjStr = OOO_STRING_SVTOOLS_RTF_TQC;
  8.2328 +                    break;
  8.2329 +                default:
  8.2330 +                    break;
  8.2331 +            }
  8.2332 +            if (pAdjStr)
  8.2333 +                m_aStyles.append(pAdjStr);
  8.2334 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TX);
  8.2335 +            m_aStyles.append((sal_Int32)(rTS.GetTabPos() + nOffset));
  8.2336 +        }
  8.2337 +        else
  8.2338 +        {
  8.2339 +            m_aTabStop.append( OOO_STRING_SVTOOLS_RTF_DEFTAB );
  8.2340 +            m_aTabStop.append( (sal_Int32)rTabStop[0].GetTabPos() );
  8.2341 +        }
  8.2342 +    }
  8.2343 +}
  8.2344 +
  8.2345 +void RtfAttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
  8.2346 +{
  8.2347 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2348 +
  8.2349 +    sal_Int32 nFlags = rHyphenZone.IsHyphen() ? 1 : 0;
  8.2350 +    if( rHyphenZone.IsPageEnd() )
  8.2351 +        nFlags += 2;
  8.2352 +    m_aStyles.append('{');
  8.2353 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_IGNORE);
  8.2354 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHEN);
  8.2355 +    m_aStyles.append((sal_Int32)nFlags);
  8.2356 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHLEAD);
  8.2357 +    m_aStyles.append((sal_Int32)rHyphenZone.GetMinLead());
  8.2358 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHTRAIL);
  8.2359 +    m_aStyles.append((sal_Int32)rHyphenZone.GetMinTrail());
  8.2360 +    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HYPHMAX);
  8.2361 +    m_aStyles.append((sal_Int32)rHyphenZone.GetMaxHyphens());
  8.2362 +    m_aStyles.append('}');
  8.2363 +}
  8.2364 +
  8.2365 +void RtfAttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId )
  8.2366 +{
  8.2367 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2368 +
  8.2369 +    if ( USHRT_MAX == nNumId || 0 == nNumId || 0 == pTxtNd)
  8.2370 +        return;
  8.2371 +
  8.2372 +    const SwNumRule* pRule = pTxtNd->GetNumRule();
  8.2373 +
  8.2374 +    // --> OD 2008-03-18 #refactorlists#
  8.2375 +    //    if( pRule && MAXLEVEL > pTxtNd->GetActualListLevel() )
  8.2376 +    if( pRule && pTxtNd->IsInList() )
  8.2377 +        // <--
  8.2378 +    {
  8.2379 +        // --> OD 2008-03-18 #refactorlists#
  8.2380 +        ASSERT( pTxtNd->GetActualListLevel() >= 0 && pTxtNd->GetActualListLevel() < MAXLEVEL,
  8.2381 +                "<SwRTFWriter::OutListNum(..)> - text node does not have valid list level. Serious defect -> please inform OD" );
  8.2382 +        // <--
  8.2383 +
  8.2384 +        const bool bExportNumRule = USHRT_MAX != nNumId;
  8.2385 +        const SwNumFmt* pFmt = pRule->GetNumFmt( nLvl );
  8.2386 +        if( !pFmt )
  8.2387 +            pFmt = &pRule->Get( nLvl );
  8.2388 +
  8.2389 +        const SfxItemSet& rNdSet = pTxtNd->GetSwAttrSet();
  8.2390 +
  8.2391 +        if ( bExportNumRule ) {
  8.2392 +            m_aStyles.append('{');
  8.2393 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LISTTEXT);
  8.2394 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PARD);
  8.2395 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_PLAIN);
  8.2396 +            m_aStyles.append(' ');
  8.2397 +        }
  8.2398 +
  8.2399 +        SvxLRSpaceItem aLR( (SvxLRSpaceItem&)rNdSet.Get( RES_LR_SPACE ) );
  8.2400 +        aLR.SetTxtLeft( aLR.GetTxtLeft() + pFmt->GetAbsLSpace() );
  8.2401 +        aLR.SetTxtFirstLineOfst( pFmt->GetFirstLineOffset() );
  8.2402 +        FormatLRSpace(aLR);
  8.2403 +
  8.2404 +        USHORT nStyle = m_rExport.GetId( *pFmt->GetCharFmt() );
  8.2405 +        OString* pString = m_rExport.GetStyle(nStyle);
  8.2406 +        if (pString)
  8.2407 +            m_aStyles.append(*pString);
  8.2408 +
  8.2409 +        {
  8.2410 +            String sTxt;
  8.2411 +            if( SVX_NUM_CHAR_SPECIAL == pFmt->GetNumberingType() || SVX_NUM_BITMAP == pFmt->GetNumberingType() )
  8.2412 +                sTxt = pFmt->GetBulletChar();
  8.2413 +            else
  8.2414 +                sTxt = pTxtNd->GetNumString();
  8.2415 +
  8.2416 +            m_aStyles.append(' ');
  8.2417 +
  8.2418 +            if (sTxt.Len())
  8.2419 +            {
  8.2420 +                m_aStyles.append(m_rExport.OutString(sTxt, m_rExport.eDefaultEncoding));
  8.2421 +            }
  8.2422 +
  8.2423 +            if( bExportNumRule )
  8.2424 +            {
  8.2425 +                if( OUTLINE_RULE != pRule->GetRuleType() )
  8.2426 +                {
  8.2427 +                    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
  8.2428 +                    m_aStyles.append('}');
  8.2429 +                    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ILVL);
  8.2430 +                    if( nLvl > 8 )            // RTF knows only 9 levels
  8.2431 +                    {
  8.2432 +                        m_aStyles.append((sal_Int32)8);
  8.2433 +                        m_aStyles.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SOUTLVL);
  8.2434 +                        m_aStyles.append((sal_Int32)nLvl);
  8.2435 +                        m_aStyles.append('}');
  8.2436 +                    }
  8.2437 +                    else
  8.2438 +                        m_aStyles.append((sal_Int32)nLvl);
  8.2439 +                    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LS);
  8.2440 +                    m_aStyles.append((sal_Int32)m_rExport.GetId(*pRule));
  8.2441 +                    m_aStyles.append(' ');
  8.2442 +                }
  8.2443 +                else
  8.2444 +                    m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB "}");
  8.2445 +            }
  8.2446 +            else if( sTxt.Len() )
  8.2447 +                m_aStyles.append(OOO_STRING_SVTOOLS_RTF_TAB);
  8.2448 +        }
  8.2449 +    }
  8.2450 +}
  8.2451 +
  8.2452 +void RtfAttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
  8.2453 +{
  8.2454 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2455 +
  8.2456 +    if (!rScriptSpace.GetValue( ))
  8.2457 +        return;
  8.2458 +    switch ( rScriptSpace.Which( ) )
  8.2459 +    {
  8.2460 +        case RES_PARATR_SCRIPTSPACE:
  8.2461 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_ASPALPHA);
  8.2462 +            break;
  8.2463 +        /* Is this needed?
  8.2464 +        case RES_PARATR_HANGINGPUNCTUATION:
  8.2465 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOOVERFLOW);
  8.2466 +            break;
  8.2467 +        case RES_PARATR_FORBIDDEN_RULES:
  8.2468 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOCWRAP);
  8.2469 +            break;*/
  8.2470 +        default:
  8.2471 +            break;
  8.2472 +    }
  8.2473 +}
  8.2474 +
  8.2475 +void RtfAttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
  8.2476 +{
  8.2477 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2478 +
  8.2479 +    const char* pStr;
  8.2480 +    switch ( rAlign.GetValue() )
  8.2481 +    {
  8.2482 +        case SvxParaVertAlignItem::TOP:         pStr = OOO_STRING_SVTOOLS_RTF_FAHANG;       break;
  8.2483 +        case SvxParaVertAlignItem::BOTTOM:      pStr = OOO_STRING_SVTOOLS_RTF_FAVAR;        break;
  8.2484 +        case SvxParaVertAlignItem::CENTER:      pStr = OOO_STRING_SVTOOLS_RTF_FACENTER;     break;
  8.2485 +        case SvxParaVertAlignItem::BASELINE:    pStr = OOO_STRING_SVTOOLS_RTF_FAROMAN;      break;
  8.2486 +        // default == SvxParaVertAlignItem::AUTOMATIC
  8.2487 +        default:                                pStr = OOO_STRING_SVTOOLS_RTF_FAAUTO;       break;
  8.2488 +    }
  8.2489 +    m_aStyles.append(pStr);
  8.2490 +}
  8.2491 +
  8.2492 +void RtfAttributeOutput::ParaSnapToGrid( const SvxParaGridItem& /*rGrid*/ )
  8.2493 +{
  8.2494 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2495 +}
  8.2496 +
  8.2497 +void RtfAttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
  8.2498 +{
  8.2499 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2500 +
  8.2501 +    if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
  8.2502 +    {
  8.2503 +        if( rSize.GetWidth() )
  8.2504 +        {
  8.2505 +            m_aRunText.append(OOO_STRING_SVTOOLS_RTF_ABSW);
  8.2506 +            m_aRunText.append((sal_Int32)rSize.GetWidth());
  8.2507 +        }
  8.2508 +
  8.2509 +        if( rSize.GetHeight() )
  8.2510 +        {
  8.2511 +            long nH = rSize.GetHeight();
  8.2512 +            if( ATT_FIX_SIZE == rSize.GetHeightSizeType() )
  8.2513 +                nH = -nH;
  8.2514 +            m_aRunText.append(OOO_STRING_SVTOOLS_RTF_ABSH);
  8.2515 +            m_aRunText.append((sal_Int32)nH);
  8.2516 +        }
  8.2517 +    }
  8.2518 +    else if (m_rExport.bOutPageDescs)
  8.2519 +    {
  8.2520 +        m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGWSXN);
  8.2521 +        m_aSectionBreaks.append((sal_Int32)rSize.GetWidth());
  8.2522 +        m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_PGHSXN);
  8.2523 +        m_aSectionBreaks.append((sal_Int32)rSize.GetHeight());
  8.2524 +        if (!m_bBufferSectionBreaks)
  8.2525 +            m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
  8.2526 +    }
  8.2527 +}
  8.2528 +
  8.2529 +void RtfAttributeOutput::FormatPaperBin( const SvxPaperBinItem& )
  8.2530 +{
  8.2531 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2532 +}
  8.2533 +
  8.2534 +void RtfAttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLRSpace )
  8.2535 +{
  8.2536 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2537 +
  8.2538 +    if ( !m_rExport.bOutFlyFrmAttrs )
  8.2539 +    {
  8.2540 +        if( m_rExport.bOutPageDescs )
  8.2541 +        {
  8.2542 +            if( rLRSpace.GetLeft() )
  8.2543 +            {
  8.2544 +                m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGLSXN);
  8.2545 +                m_aSectionBreaks.append((sal_Int32)rLRSpace.GetLeft());
  8.2546 +            }
  8.2547 +            if( rLRSpace.GetRight() )
  8.2548 +            {
  8.2549 +                m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGRSXN);
  8.2550 +                m_aSectionBreaks.append((sal_Int32)rLRSpace.GetRight());
  8.2551 +            }
  8.2552 +            if (!m_bBufferSectionBreaks)
  8.2553 +                m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
  8.2554 +        }
  8.2555 +        else
  8.2556 +        {
  8.2557 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LI);
  8.2558 +            m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
  8.2559 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RI);
  8.2560 +            m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
  8.2561 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LIN);
  8.2562 +            m_aStyles.append( (sal_Int32) rLRSpace.GetTxtLeft() );
  8.2563 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RIN);
  8.2564 +            m_aStyles.append( (sal_Int32) rLRSpace.GetRight() );
  8.2565 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_FI);
  8.2566 +            m_aStyles.append( (sal_Int32) rLRSpace.GetTxtFirstLineOfst() );
  8.2567 +        }
  8.2568 +    }
  8.2569 +}
  8.2570 +
  8.2571 +void RtfAttributeOutput::FormatULSpace( const SvxULSpaceItem& rULSpace )
  8.2572 +{
  8.2573 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2574 +
  8.2575 +    if ( !m_rExport.bOutFlyFrmAttrs )
  8.2576 +    {
  8.2577 +        if( m_rExport.bOutPageDescs )
  8.2578 +        {
  8.2579 +            if( rULSpace.GetUpper() )
  8.2580 +            {
  8.2581 +                m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGTSXN);
  8.2582 +                m_aSectionBreaks.append((sal_Int32)rULSpace.GetUpper());
  8.2583 +            }
  8.2584 +            if( rULSpace.GetLower() )
  8.2585 +            {
  8.2586 +                m_aSectionBreaks.append(OOO_STRING_SVTOOLS_RTF_MARGBSXN);
  8.2587 +                m_aSectionBreaks.append((sal_Int32)rULSpace.GetLower());
  8.2588 +            }
  8.2589 +            if (!m_bBufferSectionBreaks)
  8.2590 +                m_rExport.Strm() << m_aSectionBreaks.makeStringAndClear();
  8.2591 +        }
  8.2592 +        else
  8.2593 +        {
  8.2594 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SB);
  8.2595 +            m_aStyles.append( (sal_Int32) rULSpace.GetUpper() );
  8.2596 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_SA);
  8.2597 +            m_aStyles.append( (sal_Int32) rULSpace.GetLower() );
  8.2598 +        }
  8.2599 +    }
  8.2600 +}
  8.2601 +
  8.2602 +void RtfAttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
  8.2603 +{
  8.2604 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2605 +
  8.2606 +    if ( m_rExport.bOutFlyFrmAttrs && !m_rExport.bRTFFlySyntax )
  8.2607 +    {
  8.2608 +        SwSurround eSurround = rSurround.GetSurround();
  8.2609 +        BOOL bGold = SURROUND_IDEAL == eSurround;
  8.2610 +        if( bGold )
  8.2611 +            eSurround = SURROUND_PARALLEL;
  8.2612 +        RTFSurround aMC( bGold, static_cast< BYTE >(eSurround) );
  8.2613 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYMAINCNT);
  8.2614 +        m_aRunText.append( (sal_Int32) aMC.GetValue() );
  8.2615 +    }
  8.2616 +}
  8.2617 +
  8.2618 +void RtfAttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
  8.2619 +{
  8.2620 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2621 +
  8.2622 +    if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
  8.2623 +    {
  8.2624 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_PVPARA);
  8.2625 +
  8.2626 +        switch (rFlyVert.GetVertOrient())
  8.2627 +        {
  8.2628 +            case text::VertOrientation::TOP:
  8.2629 +            case text::VertOrientation::LINE_TOP:
  8.2630 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYT);
  8.2631 +                break;
  8.2632 +            case text::VertOrientation::BOTTOM:
  8.2633 +            case text::VertOrientation::LINE_BOTTOM:
  8.2634 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYB);
  8.2635 +                break;
  8.2636 +            case text::VertOrientation::CENTER:
  8.2637 +            case text::VertOrientation::LINE_CENTER:
  8.2638 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSYC);
  8.2639 +                break;
  8.2640 +            case text::VertOrientation::NONE:
  8.2641 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSY);
  8.2642 +                m_aRunText.append((sal_Int32)rFlyVert.GetPos());
  8.2643 +                break;
  8.2644 +            default:
  8.2645 +                break;
  8.2646 +        }
  8.2647 +    }
  8.2648 +    else if ( !m_rExport.bRTFFlySyntax )
  8.2649 +    {
  8.2650 +        RTFVertOrient aVO( static_cast< USHORT >(rFlyVert.GetVertOrient()), static_cast< USHORT >(rFlyVert.GetRelationOrient()) );
  8.2651 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYVERT);
  8.2652 +        m_aRunText.append((sal_Int32)aVO.GetValue());
  8.2653 +    }
  8.2654 +}
  8.2655 +
  8.2656 +void RtfAttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
  8.2657 +{
  8.2658 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2659 +
  8.2660 +    if ( m_rExport.bOutFlyFrmAttrs && m_rExport.bRTFFlySyntax )
  8.2661 +    {
  8.2662 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_PHCOL);
  8.2663 +
  8.2664 +        const char* pS = 0;
  8.2665 +        switch(rFlyHori.GetHoriOrient())
  8.2666 +        {
  8.2667 +            case text::HoriOrientation::RIGHT:
  8.2668 +                pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXO : OOO_STRING_SVTOOLS_RTF_POSXR;
  8.2669 +                break;
  8.2670 +            case text::HoriOrientation::LEFT:
  8.2671 +                pS = rFlyHori.IsPosToggle() ? OOO_STRING_SVTOOLS_RTF_POSXI : OOO_STRING_SVTOOLS_RTF_POSXL;
  8.2672 +                break;
  8.2673 +            case text::HoriOrientation::CENTER:
  8.2674 +                pS = OOO_STRING_SVTOOLS_RTF_POSXC;
  8.2675 +                break;
  8.2676 +            case text::HoriOrientation::NONE:
  8.2677 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_POSX);
  8.2678 +                m_aRunText.append((sal_Int32)rFlyHori.GetPos());
  8.2679 +                break;
  8.2680 +            default:
  8.2681 +                break;
  8.2682 +        }
  8.2683 +        if (pS)
  8.2684 +            m_aRunText.append(pS);
  8.2685 +    } else if ( !m_rExport.bRTFFlySyntax )
  8.2686 +    {
  8.2687 +        RTFHoriOrient aHO( static_cast< USHORT >(rFlyHori.GetHoriOrient()),
  8.2688 +                static_cast< USHORT >(rFlyHori.GetRelationOrient()) );
  8.2689 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYHORZ);
  8.2690 +        m_aRunText.append((sal_Int32)aHO.GetValue());
  8.2691 +    }
  8.2692 +}
  8.2693 +
  8.2694 +void RtfAttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
  8.2695 +{
  8.2696 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2697 +
  8.2698 +    if ( !m_rExport.bRTFFlySyntax )
  8.2699 +    {
  8.2700 +        USHORT nId = static_cast< USHORT >(rAnchor.GetAnchorId());
  8.2701 +        m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYANCHOR);
  8.2702 +        m_aRunText.append((sal_Int32)nId);
  8.2703 +        switch( nId )
  8.2704 +        {
  8.2705 +            case FLY_PAGE:
  8.2706 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYPAGE);
  8.2707 +                m_aRunText.append((sal_Int32)rAnchor.GetPageNum());
  8.2708 +                break;
  8.2709 +            case FLY_AT_CNTNT:
  8.2710 +            case FLY_IN_CNTNT:
  8.2711 +                m_aRunText.append(OOO_STRING_SVTOOLS_RTF_FLYCNTNT);
  8.2712 +                break;
  8.2713 +        }
  8.2714 +    }
  8.2715 +}
  8.2716 +
  8.2717 +void RtfAttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
  8.2718 +{
  8.2719 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2720 +
  8.2721 +    if( !rBrush.GetColor().GetTransparency() )
  8.2722 +    {
  8.2723 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
  8.2724 +        m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
  8.2725 +    }
  8.2726 +}
  8.2727 +
  8.2728 +void RtfAttributeOutput::FormatBox( const SvxBoxItem& rBox )
  8.2729 +{
  8.2730 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2731 +
  8.2732 +    static USHORT __READONLY_DATA aBorders[] = {
  8.2733 +        BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT };
  8.2734 +    static const sal_Char* aBorderNames[] = {
  8.2735 +        OOO_STRING_SVTOOLS_RTF_BRDRT, OOO_STRING_SVTOOLS_RTF_BRDRL, OOO_STRING_SVTOOLS_RTF_BRDRB, OOO_STRING_SVTOOLS_RTF_BRDRR };
  8.2736 +
  8.2737 +    USHORT nDist = rBox.GetDistance();
  8.2738 +
  8.2739 +    if( rBox.GetTop() && rBox.GetBottom() &&
  8.2740 +            rBox.GetLeft() && rBox.GetRight() &&
  8.2741 +            *rBox.GetTop() == *rBox.GetBottom() &&
  8.2742 +            *rBox.GetTop() == *rBox.GetLeft() &&
  8.2743 +            *rBox.GetTop() == *rBox.GetRight() &&
  8.2744 +            nDist == rBox.GetDistance( BOX_LINE_TOP ) &&
  8.2745 +            nDist == rBox.GetDistance( BOX_LINE_LEFT ) &&
  8.2746 +            nDist == rBox.GetDistance( BOX_LINE_BOTTOM ) &&
  8.2747 +            nDist == rBox.GetDistance( BOX_LINE_RIGHT ))
  8.2748 +        m_aSectionBreaks.append(OutBorderLine( m_rExport, rBox.GetTop(), OOO_STRING_SVTOOLS_RTF_BOX, nDist ));
  8.2749 +    else
  8.2750 +    {
  8.2751 +        const USHORT* pBrd = aBorders;
  8.2752 +        const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
  8.2753 +        for(int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms)
  8.2754 +        {
  8.2755 +            if (const SvxBorderLine* pLn = rBox.GetLine(*pBrd))
  8.2756 +            {
  8.2757 +                m_aSectionBreaks.append(OutBorderLine(m_rExport, pLn, *pBrdNms,
  8.2758 +                        rBox.GetDistance(*pBrd)));
  8.2759 +            }
  8.2760 +        }
  8.2761 +    }
  8.2762 +
  8.2763 +    const USHORT* pBrd = aBorders;
  8.2764 +    const sal_Char** pBrdNms = (const sal_Char**)aBorderNames;
  8.2765 +    for( int i = 0; i < 4; ++i, ++pBrd, ++pBrdNms )
  8.2766 +    {
  8.2767 +        const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
  8.2768 +        if( pLn )
  8.2769 +        {
  8.2770 +            m_aSectionBreaks.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE);
  8.2771 +            m_aSectionBreaks.append(OutBorderLine( m_rExport, pLn, *pBrdNms ));
  8.2772 +            m_aSectionBreaks.append("}" OOO_STRING_SVTOOLS_RTF_BRSP);
  8.2773 +            m_aSectionBreaks.append((sal_Int32)rBox.GetDistance( *pBrd ));
  8.2774 +        }
  8.2775 +    }
  8.2776 +
  8.2777 +    if (!m_bBufferSectionBreaks)
  8.2778 +        m_aStyles.append(m_aSectionBreaks.makeStringAndClear());
  8.2779 +}
  8.2780 +
  8.2781 +void RtfAttributeOutput::FormatColumns_Impl( USHORT nCols, const SwFmtCol& rCol, bool bEven, SwTwips nPageSize )
  8.2782 +{
  8.2783 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2784 +
  8.2785 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLS;
  8.2786 +    m_rExport.OutLong( nCols );
  8.2787 +
  8.2788 +    if( bEven )
  8.2789 +    {
  8.2790 +        m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSX;
  8.2791 +        m_rExport.OutLong( rCol.GetGutterWidth( TRUE ) );
  8.2792 +    }
  8.2793 +    else
  8.2794 +    {
  8.2795 +        const SwColumns & rColumns = rCol.GetColumns( );
  8.2796 +        for( USHORT n = 0; n < nCols; )
  8.2797 +        {
  8.2798 +            m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLNO;
  8.2799 +            m_rExport.OutLong( n+1 );
  8.2800 +
  8.2801 +            m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLW;
  8.2802 +            m_rExport.OutLong( rCol.CalcPrtColWidth( n, nPageSize ) );
  8.2803 +
  8.2804 +            if( ++n != nCols )
  8.2805 +            {
  8.2806 +                m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_COLSR;
  8.2807 +                m_rExport.OutLong( rColumns[ n-1 ]->GetRight() +
  8.2808 +                        rColumns[ n ]->GetLeft() );
  8.2809 +            }
  8.2810 +        }
  8.2811 +    }
  8.2812 +}
  8.2813 +
  8.2814 +void RtfAttributeOutput::FormatKeep( const SvxFmtKeepItem& rItem )
  8.2815 +{
  8.2816 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2817 +
  8.2818 +    if( rItem.GetValue() )
  8.2819 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_KEEPN);
  8.2820 +}
  8.2821 +
  8.2822 +void RtfAttributeOutput::FormatTextGrid( const SwTextGridItem& /*rGrid*/ )
  8.2823 +{
  8.2824 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2825 +}
  8.2826 +
  8.2827 +void RtfAttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
  8.2828 +{
  8.2829 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2830 +
  8.2831 +    if ( !rNumbering.IsCount( ) )
  8.2832 +        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_NOLINE);
  8.2833 +}
  8.2834 +
  8.2835 +void RtfAttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
  8.2836 +{
  8.2837 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2838 +
  8.2839 +    if (!m_rExport.bOutPageDescs)
  8.2840 +    {
  8.2841 +        if (rDirection.GetValue() == FRMDIR_HORI_RIGHT_TOP)
  8.2842 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_RTLPAR);
  8.2843 +        else
  8.2844 +            m_aStyles.append(OOO_STRING_SVTOOLS_RTF_LTRPAR);
  8.2845 +    }
  8.2846 +}
  8.2847 +
  8.2848 +void RtfAttributeOutput::WriteExpand( const SwField* /*pFld*/ )
  8.2849 +{
  8.2850 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2851 +}
  8.2852 +
  8.2853 +void RtfAttributeOutput::RefField( const SwField& /*rFld*/, const String& /*rRef*/ )
  8.2854 +{
  8.2855 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2856 +}
  8.2857 +
  8.2858 +void RtfAttributeOutput::HiddenField( const SwField& /*rFld*/ )
  8.2859 +{
  8.2860 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2861 +}
  8.2862 +
  8.2863 +void RtfAttributeOutput::SetField( const SwField& /*rFld*/, ww::eField /*eType*/, const String& /*rCmd*/ )
  8.2864 +{
  8.2865 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  8.2866 +}
  8.2867 +
  8.2868 +void RtfAttributeOutput::PostitField( const SwField* pFld )
  8.2869 +{
  8.2870 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2871 +
  8.2872 +    const SwPostItField& rPFld = *(SwPostItField*)pFld;
  8.2873 +
  8.2874 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNID " ");
  8.2875 +    m_aRunText.append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
  8.2876 +    m_aRunText.append("}");
  8.2877 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNAUTHOR " ");
  8.2878 +    m_aRunText.append(OUStringToOString(OUString(rPFld.GetPar1()), m_rExport.eCurrentEncoding));
  8.2879 +    m_aRunText.append("}");
  8.2880 +    m_aRunText.append(OOO_STRING_SVTOOLS_RTF_CHATN);
  8.2881 +
  8.2882 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ANNOTATION);
  8.2883 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_ATNDATE " ");
  8.2884 +    m_aRunText.append((sal_Int32)sw::ms::DateTime2DTTM(rPFld.GetDate()));
  8.2885 +    m_aRunText.append('}');
  8.2886 +    m_aRunText.append(OUStringToOString(OUString(rPFld.GetTxt()), m_rExport.eCurrentEncoding));
  8.2887 +    m_aRunText.append('}');
  8.2888 +}
  8.2889 +
  8.2890 +bool RtfAttributeOutput::DropdownField( const SwField* /*pFld*/ )
  8.2891 +{
  8.2892 +    // this is handled in OutputFlyFrame_Impl()
  8.2893 +    return true;
  8.2894 +}
  8.2895 +
  8.2896 +RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
  8.2897 +    : m_rExport( rExport ),
  8.2898 +    m_pTableWrt( NULL ),
  8.2899 +    m_bTableCellOpen( false ),
  8.2900 +    m_nTableDepth( 0 ),
  8.2901 +    m_bTblAfterCell( false ),
  8.2902 +    m_nColBreakNeeded( false ),
  8.2903 +    m_bBufferSectionBreaks( false ),
  8.2904 +    m_bBufferSectionHeaders( false )
  8.2905 +{
  8.2906 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2907 +}
  8.2908 +
  8.2909 +RtfAttributeOutput::~RtfAttributeOutput()
  8.2910 +{
  8.2911 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2912 +}
  8.2913 +
  8.2914 +MSWordExportBase& RtfAttributeOutput::GetExport()
  8.2915 +{
  8.2916 +    return m_rExport;
  8.2917 +}
  8.2918 +
  8.2919 +// These are used by wwFont::WriteRtf()
  8.2920 +
  8.2921 +/// Start the font.
  8.2922 +void RtfAttributeOutput::StartFont( const String& rFamilyName ) const
  8.2923 +{
  8.2924 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2925 +
  8.2926 +    m_rExport.Strm() << OUStringToOString( OUString( rFamilyName ), m_rExport.eCurrentEncoding ).getStr();
  8.2927 +}
  8.2928 +
  8.2929 +/// End the font.
  8.2930 +void RtfAttributeOutput::EndFont() const
  8.2931 +{
  8.2932 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2933 +
  8.2934 +    m_rExport.Strm() << ";}";
  8.2935 +}
  8.2936 +
  8.2937 +/// Alternate name for the font.
  8.2938 +void RtfAttributeOutput::FontAlternateName( const String& rName ) const
  8.2939 +{
  8.2940 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2941 +
  8.2942 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_FALT << ' ';
  8.2943 +    m_rExport.Strm() << OUStringToOString( OUString( rName ), m_rExport.eCurrentEncoding ) << '}';
  8.2944 +}
  8.2945 +
  8.2946 +/// Font charset.
  8.2947 +void RtfAttributeOutput::FontCharset( sal_uInt8 nCharSet ) const
  8.2948 +{
  8.2949 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2950 +
  8.2951 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FCHARSET;
  8.2952 +    m_rExport.OutULong( nCharSet );
  8.2953 +    m_rExport.Strm() << ' ';
  8.2954 +}
  8.2955 +
  8.2956 +/// Font family.
  8.2957 +void RtfAttributeOutput::FontFamilyType( FontFamily eFamily, const wwFont &rFont ) const
  8.2958 +{
  8.2959 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2960 +
  8.2961 +    m_rExport.Strm() << '{' << OOO_STRING_SVTOOLS_RTF_F;
  8.2962 +
  8.2963 +    const char* pStr = OOO_STRING_SVTOOLS_RTF_FNIL;
  8.2964 +    switch (eFamily)
  8.2965 +    {
  8.2966 +        case FAMILY_ROMAN:
  8.2967 +            pStr = OOO_STRING_SVTOOLS_RTF_FROMAN;
  8.2968 +            break;
  8.2969 +        case FAMILY_SWISS:
  8.2970 +            pStr = OOO_STRING_SVTOOLS_RTF_FSWISS;
  8.2971 +            break;
  8.2972 +        case FAMILY_MODERN:
  8.2973 +            pStr = OOO_STRING_SVTOOLS_RTF_FMODERN;
  8.2974 +            break;
  8.2975 +        case FAMILY_SCRIPT:
  8.2976 +            pStr = OOO_STRING_SVTOOLS_RTF_FSCRIPT;
  8.2977 +            break;
  8.2978 +        case FAMILY_DECORATIVE:
  8.2979 +            pStr = OOO_STRING_SVTOOLS_RTF_FDECOR;
  8.2980 +            break;
  8.2981 +        default:
  8.2982 +            break;
  8.2983 +    }
  8.2984 +    m_rExport.OutULong(m_rExport.maFontHelper.GetId(rFont)) << pStr;
  8.2985 +}
  8.2986 +
  8.2987 +/// Font pitch.
  8.2988 +void RtfAttributeOutput::FontPitchType( FontPitch ePitch ) const
  8.2989 +{
  8.2990 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.2991 +
  8.2992 +    m_rExport.Strm() << OOO_STRING_SVTOOLS_RTF_FPRQ;
  8.2993 +
  8.2994 +    USHORT nVal = 0;
  8.2995 +    switch (ePitch)
  8.2996 +    {
  8.2997 +        case PITCH_FIXED:
  8.2998 +            nVal = 1;
  8.2999 +            break;
  8.3000 +        case PITCH_VARIABLE:
  8.3001 +            nVal = 2;
  8.3002 +            break;
  8.3003 +        default:
  8.3004 +            break;
  8.3005 +    }
  8.3006 +    m_rExport.OutULong(nVal);
  8.3007 +}
  8.3008 +
  8.3009 +static bool IsEMF(const sal_uInt8 *pGraphicAry, unsigned long nSize)
  8.3010 +{
  8.3011 +    if (pGraphicAry && (nSize > 0x2c ))
  8.3012 +    {
  8.3013 +        // check the magic number
  8.3014 +        if (
  8.3015 +                (pGraphicAry[0x28] == 0x20 ) && (pGraphicAry[0x29] == 0x45) &&
  8.3016 +                (pGraphicAry[0x2a] == 0x4d ) && (pGraphicAry[0x2b] == 0x46)
  8.3017 +           )
  8.3018 +        {
  8.3019 +            //emf detected
  8.3020 +            return true;
  8.3021 +        }
  8.3022 +    }
  8.3023 +    return false;
  8.3024 +}
  8.3025 +
  8.3026 +static bool StripMetafileHeader(const sal_uInt8 *&rpGraphicAry, unsigned long &rSize)
  8.3027 +{
  8.3028 +    if (rpGraphicAry && (rSize > 0x22))
  8.3029 +    {
  8.3030 +        if (
  8.3031 +             (rpGraphicAry[0] == 0xd7) && (rpGraphicAry[1] == 0xcd) &&
  8.3032 +             (rpGraphicAry[2] == 0xc6) && (rpGraphicAry[3] == 0x9a)
  8.3033 +           )
  8.3034 +        {   // we have to get rid of the metafileheader
  8.3035 +            rpGraphicAry += 22;
  8.3036 +            rSize -= 22;
  8.3037 +            return true;
  8.3038 +        }
  8.3039 +    }
  8.3040 +    return false;
  8.3041 +}
  8.3042 +
  8.3043 +static OString WriteHex(const sal_uInt8* pData, sal_uInt32 nSize, sal_uInt32 nLimit = 64)
  8.3044 +{
  8.3045 +    OStringBuffer aRet;
  8.3046 +
  8.3047 +    sal_uInt32 nBreak = 0;
  8.3048 +    for (sal_uInt32 i = 0; i < nSize; i++)
  8.3049 +    {
  8.3050 +        OString sNo = OString::valueOf(sal_Int32(pData[i]), 16);
  8.3051 +        if (sNo.getLength() < 2)
  8.3052 +            aRet.append('0');
  8.3053 +        aRet.append(sNo);
  8.3054 +        if (++nBreak == nLimit)
  8.3055 +        {
  8.3056 +            aRet.append(RtfExport::sNewLine);
  8.3057 +            nBreak = 0;
  8.3058 +        }
  8.3059 +    }
  8.3060 +
  8.3061 +    return aRet.makeStringAndClear();
  8.3062 +}
  8.3063 +
  8.3064 +static OString WriteHex(sal_Int32 nNum)
  8.3065 +{
  8.3066 +    return WriteHex((sal_uInt8*)&nNum, sizeof(sal_Int32));
  8.3067 +}
  8.3068 +
  8.3069 +static OString WriteHex(OString sString)
  8.3070 +{
  8.3071 +    OStringBuffer aRet;
  8.3072 +
  8.3073 +    aRet.append(WriteHex(sString.getLength()+1));
  8.3074 +    aRet.append(WriteHex((sal_uInt8*)sString.getStr(), sString.getLength()+1));
  8.3075 +
  8.3076 +    return aRet.makeStringAndClear();
  8.3077 +}
  8.3078 +
  8.3079 +static OString ExportPICT(const Size &rOrig, const Size &rRendered, const Size &rMapped,
  8.3080 +    const SwCropGrf &rCr, const char *pBLIPType, const sal_uInt8 *pGraphicAry,
  8.3081 +    unsigned long nSize)
  8.3082 +{
  8.3083 +    OStringBuffer aRet;
  8.3084 +    bool bIsWMF = (const char *)pBLIPType == (const char *)OOO_STRING_SVTOOLS_RTF_WMETAFILE ? true : false;
  8.3085 +    if (pBLIPType && nSize && pGraphicAry)
  8.3086 +    {
  8.3087 +        aRet.append("{" OOO_STRING_SVTOOLS_RTF_PICT);
  8.3088 +
  8.3089 +        long nXCroppedSize = rOrig.Width()-(rCr.GetLeft() + rCr.GetRight());
  8.3090 +        long nYCroppedSize = rOrig.Height()-(rCr.GetTop() + rCr.GetBottom());
  8.3091 +        /* #127543#: Graphic with a zero height or width, typically copied from webpages, caused
  8.3092 +           crashes. */
  8.3093 +        if( !nXCroppedSize )
  8.3094 +            nXCroppedSize = 100;
  8.3095 +        if( !nYCroppedSize )
  8.3096 +            nYCroppedSize = 100;
  8.3097 +
  8.3098 +        //Given the original size and taking cropping into account
  8.3099 +        //first, how much has the original been scaled to get the
  8.3100 +        //final rendered size
  8.3101 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEX);
  8.3102 +        aRet.append((sal_Int32)((100 * rRendered.Width()) / nXCroppedSize));
  8.3103 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICSCALEY);
  8.3104 +        aRet.append((sal_Int32)((100 * rRendered.Height()) / nYCroppedSize));
  8.3105 +
  8.3106 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPL);
  8.3107 +        aRet.append((sal_Int32)rCr.GetLeft());
  8.3108 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPR);
  8.3109 +        aRet.append((sal_Int32)rCr.GetRight());
  8.3110 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPT);
  8.3111 +        aRet.append((sal_Int32)rCr.GetTop());
  8.3112 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICCROPB);
  8.3113 +        aRet.append((sal_Int32)rCr.GetBottom());
  8.3114 +
  8.3115 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICW);
  8.3116 +        aRet.append((sal_Int32)rMapped.Width());
  8.3117 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICH);
  8.3118 +        aRet.append((sal_Int32)rMapped.Height());
  8.3119 +
  8.3120 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICWGOAL);
  8.3121 +        aRet.append((sal_Int32)rOrig.Width());
  8.3122 +        aRet.append(OOO_STRING_SVTOOLS_RTF_PICHGOAL);
  8.3123 +        aRet.append((sal_Int32)rOrig.Height());
  8.3124 +
  8.3125 +        aRet.append(pBLIPType);
  8.3126 +        if (bIsWMF)
  8.3127 +        {
  8.3128 +            aRet.append((sal_Int32)8);
  8.3129 +            StripMetafileHeader(pGraphicAry, nSize);
  8.3130 +        }
  8.3131 +        aRet.append(RtfExport::sNewLine);
  8.3132 +        aRet.append(WriteHex(pGraphicAry, nSize));
  8.3133 +        aRet.append('}');
  8.3134 +    }
  8.3135 +    return aRet.makeStringAndClear();
  8.3136 +}
  8.3137 +
  8.3138 +void RtfAttributeOutput::FlyFrameOLEData( SwOLENode& rOLENode )
  8.3139 +{
  8.3140 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.3141 +
  8.3142 +    uno::Reference < embed::XEmbeddedObject > xObj(const_cast<SwOLENode&>(rOLENode).GetOLEObj().GetOleRef());
  8.3143 +    sal_Int64 nAspect = rOLENode.GetAspect();
  8.3144 +    svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
  8.3145 +    SvGlobalName aObjName(aObjRef->getClassID());
  8.3146 +
  8.3147 +    if (SotExchange::IsMath(aObjName))
  8.3148 +    {
  8.3149 +        // ObjectHeader
  8.3150 +        m_aRunText.append(WriteHex(0x00000501)); // OLEVersion
  8.3151 +        m_aRunText.append(WriteHex(0x00000002)); // FormatID
  8.3152 +        m_aRunText.append(WriteHex(OString("Equation.3"))); // ClassName
  8.3153 +        m_aRunText.append(WriteHex(0x00000000)); // TopicName
  8.3154 +        m_aRunText.append(WriteHex(0x00000000)); // ItemName
  8.3155 +
  8.3156 +        // NativeData
  8.3157 +        SvMemoryStream *pStream = new SvMemoryStream;
  8.3158 +        SvStorage* pStorage = new SvStorage(*pStream);
  8.3159 +        m_rExport.pOLEExp->ExportOLEObject( aObjRef, *pStorage );
  8.3160 +        pStream->Seek(STREAM_SEEK_TO_END);
  8.3161 +        sal_uInt32 nNativeDataSize = pStream->Tell();
  8.3162 +        const sal_uInt8* pNativeData = (sal_uInt8*)pStream->GetData();
  8.3163 +        m_aRunText.append(WriteHex(nNativeDataSize));
  8.3164 +        m_aRunText.append(RtfExport::sNewLine);
  8.3165 +        m_aRunText.append(WriteHex(pNativeData, nNativeDataSize, 126));
  8.3166 +        m_aRunText.append(RtfExport::sNewLine);
  8.3167 +        delete pStream;
  8.3168 +
  8.3169 +        // MetaFilePresentationObject
  8.3170 +        pStream = new SvMemoryStream;
  8.3171 +        Graphic* pGraphic = rOLENode.GetGraphic();
  8.3172 +        if (GraphicConverter::Export(*pStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
  8.3173 +            OSL_ENSURE(false, "failed to export the presentation data");
  8.3174 +        pStream->Seek(STREAM_SEEK_TO_END);
  8.3175 +        sal_uInt32 nPresentationDataSize = pStream->Tell();
  8.3176 +        const sal_uInt8* pPresentationData = (sal_uInt8*)pStream->GetData();
  8.3177 +        m_aRunText.append(WriteHex(pPresentationData, nPresentationDataSize, 126));
  8.3178 +    }
  8.3179 +}
  8.3180 +
  8.3181 +void RtfAttributeOutput::FlyFrameOLE( SwOLENode& rOLENode, const Size& rSize )
  8.3182 +{
  8.3183 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.3184 +
  8.3185 +    SvMemoryStream aStream;
  8.3186 +    const sal_uInt8* pGraphicAry = 0;
  8.3187 +    sal_uInt32 nSize = 0;
  8.3188 +    Graphic* pGraphic = rOLENode.GetGraphic();
  8.3189 +
  8.3190 +    Size aSize(sw::util::GetSwappedInSize(rOLENode));
  8.3191 +    Size aRendered(aSize);
  8.3192 +    aRendered.Width() = rSize.Width();
  8.3193 +    aRendered.Height() = rSize.Height();
  8.3194 +    Size aMapped(pGraphic->GetPrefSize());
  8.3195 +    const SwCropGrf &rCr = (const SwCropGrf &)rOLENode.GetAttr(RES_GRFATR_CROPGRF);
  8.3196 +    const sal_Char* pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
  8.3197 +
  8.3198 +    if (GraphicConverter::Export(aStream, *pGraphic, CVT_WMF) != ERRCODE_NONE)
  8.3199 +        OSL_ENSURE(false, "failed to export the graphic");
  8.3200 +    aStream.Seek(STREAM_SEEK_TO_END);
  8.3201 +    nSize = aStream.Tell();
  8.3202 +    pGraphicAry = (sal_uInt8*)aStream.GetData();
  8.3203 +
  8.3204 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_OBJECT OOO_STRING_SVTOOLS_RTF_OBJEMB);
  8.3205 +
  8.3206 +    // export the object data in the appropriate format; RTF requires the usage of the OLE 1.0 format
  8.3207 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_OBJDATA " ");
  8.3208 +    FlyFrameOLEData(rOLENode);
  8.3209 +    m_aRunText.append("}{" OOO_STRING_SVTOOLS_RTF_RESULT);
  8.3210 +
  8.3211 +    SwTwips nHeight = aSize.Height();
  8.3212 +    nHeight/=20; //nHeight was in twips, want it in half points, but then half of total height.
  8.3213 +    long nFontHeight = ((const SvxFontHeightItem&)m_rExport.GetItem(RES_CHRATR_FONTSIZE)).GetHeight();
  8.3214 +    nHeight-=nFontHeight/20;
  8.3215 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_DN).append(nHeight);
  8.3216 +    m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
  8.3217 +    m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize));
  8.3218 +    m_aRunText.append("}}}}");
  8.3219 +}
  8.3220 +
  8.3221 +void RtfAttributeOutput::FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize )
  8.3222 +{
  8.3223 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  8.3224 +
  8.3225 +    SvMemoryStream aStream;
  8.3226 +    const sal_uInt8* pGraphicAry = 0;
  8.3227 +    sal_uInt32 nSize = 0;
  8.3228 +
  8.3229 +    Graphic aGraphic(rGrfNode.GetGrf());
  8.3230 +
  8.3231 +    // If there is no graphic there is not much point in parsing it
  8.3232 +    if(aGraphic.GetType()==GRAPHIC_NONE)
  8.3233 +        return;
  8.3234 +
  8.3235 +    GfxLink aGraphicLink;
  8.3236 +    const sal_Char* pBLIPType = 0;
  8.3237 +    if (aGraphic.IsLink())
  8.3238 +    {
  8.3239 +        aGraphicLink = aGraphic.GetLink();
  8.3240 +        nSize = aGraphicLink.GetDataSize();
  8.3241 +        pGraphicAry = aGraphicLink.GetData();
  8.3242 +        switch (aGraphicLink.GetType())
  8.3243 +        {
  8.3244 +            case GFX_LINK_TYPE_NATIVE_JPG:
  8.3245 +                pBLIPType = OOO_STRING_SVTOOLS_RTF_JPEGBLIP;
  8.3246 +                break;
  8.3247 +            case GFX_LINK_TYPE_NATIVE_PNG:
  8.3248 +                pBLIPType = OOO_STRING_SVTOOLS_RTF_PNGBLIP;
  8.3249 +                break;
  8.3250 +            case GFX_LINK_TYPE_NATIVE_WMF:
  8.3251 +                pBLIPType =
  8.3252 +                    IsEMF(pGraphicAry, nSize) ? OOO_STRING_SVTOOLS_RTF_EMFBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
  8.3253 +                break;
  8.3254 +            default:
  8.3255 +                break;
  8.3256 +        }
  8.3257 +    }
  8.3258 +
  8.3259 +    GraphicType eGraphicType = aGraphic.GetType();
  8.3260 +    if (!pGraphicAry)
  8.3261 +    {
  8.3262 +        if (ERRCODE_NONE == GraphicConverter::Export(aStream, aGraphic,
  8.3263 +                    (eGraphicType == GRAPHIC_BITMAP) ? CVT_PNG : CVT_WMF))
  8.3264 +        {
  8.3265 +            pBLIPType = (eGraphicType == GRAPHIC_BITMAP) ?
  8.3266 +                OOO_STRING_SVTOOLS_RTF_PNGBLIP : OOO_STRING_SVTOOLS_RTF_WMETAFILE;
  8.3267 +            aStream.Seek(STREAM_SEEK_TO_END);
  8.3268 +            nSize = aStream.Tell();
  8.3269 +            pGraphicAry = (sal_uInt8*)aStream.GetData();
  8.3270 +        }
  8.3271 +    }
  8.3272 +
  8.3273 +    Size aMapped(eGraphicType == GRAPHIC_BITMAP ? aGraphic.GetSizePixel() : aGraphic.GetPrefSize());
  8.3274 +
  8.3275 +    const SwCropGrf &rCr = (const SwCropGrf &)rGrfNode.GetAttr(RES_GRFATR_CROPGRF);
  8.3276 +
  8.3277 +    //Get original size in twips
  8.3278 +    Size aSize(sw::util::GetSwappedInSize(rGrfNode));
  8.3279 +    Size aRendered(aSize);
  8.3280 +    aRendered.Width() = rSize.Width();
  8.3281 +    aRendered.Height() = rSize.Height();
  8.3282 +
  8.3283 +    /*
  8.3284 +       If the graphic is not of type WMF then we will have to store two
  8.3285 +       graphics, one in the native format wrapped in shppict, and the other in
  8.3286 +       the wmf format wrapped in nonshppict, so as to keep wordpad happy. If its
  8.3287 +       a wmf already then we don't need any such wrapping
  8.3288 +       */
  8.3289 +    bool bIsWMF = (const sal_Char*)pBLIPType == (const sal_Char*)OOO_STRING_SVTOOLS_RTF_WMETAFILE ? true : false;
  8.3290 +    if (!bIsWMF)
  8.3291 +        m_aRunText.append("{" OOO_STRING_SVTOOLS_RTF_IGNORE OOO_STRING_SVTOOLS_RTF_SHPPICT);
  8.3292 +
  8.3293 +    if (pBLIPType)
  8.3294 +        m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize));
  8.3295 +    else
  8.3296 +    {
  8.3297 +        aStream.Seek(0);
  8.3298 +        GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
  8.3299 +        pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
  8.3300 +        aStream.Seek(STREAM_SEEK_TO_END);
  8.3301 +        nSize = aStream.Tell();
  8.3302 +        pGraphicAry = (sal_uInt8*)aStream.GetData();
  8.3303 +
  8.3304 +        m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize));
  8.3305 +    }
  8.3306 +
  8.3307 +    if (!bIsWMF)
  8.3308 +    {
  8.3309 +        m_aRunText.append("}" "{" OOO_STRING_SVTOOLS_RTF_NONSHPPICT);
  8.3310 +
  8.3311 +        aStream.Seek(0);
  8.3312 +        GraphicConverter::Export(aStream, aGraphic, CVT_WMF);
  8.3313 +        pBLIPType = OOO_STRING_SVTOOLS_RTF_WMETAFILE;
  8.3314 +        aStream.Seek(STREAM_SEEK_TO_END);
  8.3315 +        nSize = aStream.Tell();
  8.3316 +        pGraphicAry = (sal_uInt8*)aStream.GetData();
  8.3317 +
  8.3318 +        m_aRunText.append(ExportPICT(aSize, aRendered, aMapped, rCr, pBLIPType, pGraphicAry, nSize));
  8.3319 +
  8.3320 +        m_aRunText.append('}');
  8.3321 +    }
  8.3322 +
  8.3323 +    m_aRunText.append(m_rExport.sNewLine);
  8.3324 +}
  8.3325 +
  8.3326 +/* vi:set shiftwidth=4 expandtab: */
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/sw/source/filter/ww8/rtfattributeoutput.hxx	Thu Jul 29 22:01:25 2010 +0200
     9.3 @@ -0,0 +1,572 @@
     9.4 +/*************************************************************************
     9.5 + *
     9.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     9.7 + *
     9.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
     9.9 + * Copyright 2010 Miklos Vajna.
    9.10 + *
    9.11 + * OpenOffice.org - a multi-platform office productivity suite
    9.12 + *
    9.13 + * This file is part of OpenOffice.org.
    9.14 + *
    9.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
    9.16 + * it under the terms of the GNU Lesser General Public License version 3
    9.17 + * only, as published by the Free Software Foundation.
    9.18 + *
    9.19 + * OpenOffice.org is distributed in the hope that it will be useful,
    9.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    9.22 + * GNU Lesser General Public License version 3 for more details
    9.23 + * (a copy is included in the LICENSE file that accompanied this code).
    9.24 + *
    9.25 + * You should have received a copy of the GNU Lesser General Public License
    9.26 + * version 3 along with OpenOffice.org.  If not, see
    9.27 + * <http://www.openoffice.org/license.html>
    9.28 + * for a copy of the LGPLv3 License.
    9.29 + *
    9.30 + ************************************************************************/
    9.31 +
    9.32 +#ifndef _RTFATTRIBUTEOUTPUT_HXX_
    9.33 +#define _RTFATTRIBUTEOUTPUT_HXX_
    9.34 +
    9.35 +#include "attributeoutputbase.hxx"
    9.36 +#include "fields.hxx"
    9.37 +
    9.38 +#include <vcl/vclenum.hxx>
    9.39 +
    9.40 +#include <fldbas.hxx>
    9.41 +#include <rtl/strbuf.hxx>
    9.42 +
    9.43 +#include <vector>
    9.44 +
    9.45 +class RtfExport;
    9.46 +
    9.47 +class SwGrfNode;
    9.48 +class SwOLENode;
    9.49 +class SdrObject;
    9.50 +
    9.51 +class RtfAttributeOutput : public AttributeOutputBase
    9.52 +{
    9.53 +public:
    9.54 +    /// Export the state of RTL/CJK.
    9.55 +    virtual void RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript );
    9.56 +
    9.57 +    /// Start of the paragraph.
    9.58 +    virtual void StartParagraph( ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo );
    9.59 +
    9.60 +    /// End of the paragraph.
    9.61 +    virtual void EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner );
    9.62 +
    9.63 +    /// Empty paragraph.
    9.64 +    virtual void EmptyParagraph();
    9.65 +
    9.66 +    /// Called before we start outputting the attributes.
    9.67 +    virtual void StartParagraphProperties( const SwTxtNode& rNode );
    9.68 +
    9.69 +    /// Called after we end outputting the attributes.
    9.70 +    virtual void EndParagraphProperties();
    9.71 +
    9.72 +    /// Start of the text run.
    9.73 +    virtual void StartRun( const SwRedlineData* pRedlineData );
    9.74 +
    9.75 +    /// End of the text run.
    9.76 +    virtual void EndRun();
    9.77 +
    9.78 +    /// Called before we start outputting the attributes.
    9.79 +    virtual void StartRunProperties();
    9.80 +
    9.81 +    /// Called after we end outputting the attributes.
    9.82 +    virtual void EndRunProperties( const SwRedlineData* pRedlineData );
    9.83 +
    9.84 +    /// Output text (inside a run).
    9.85 +    virtual void RunText( const String& rText, rtl_TextEncoding eCharSet = RTL_TEXTENCODING_UTF8 );
    9.86 +
    9.87 +    // Access to (anyway) private buffers, used by the sdr exporter
    9.88 +    rtl::OStringBuffer& RunText();
    9.89 +    rtl::OStringBuffer& Styles();
    9.90 +    
    9.91 +    /// Output text (without markup).
    9.92 +    virtual void RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet );
    9.93 +
    9.94 +    /// Output ruby start.
    9.95 +    virtual void StartRuby( const SwTxtNode& rNode, xub_StrLen nPos, const SwFmtRuby& rRuby );
    9.96 +
    9.97 +    /// Output ruby end.
    9.98 +    virtual void EndRuby();
    9.99 +
   9.100 +    /// Output URL start.
   9.101 +    virtual bool StartURL( const String& rUrl, const String& rTarget );
   9.102 +
   9.103 +    /// Output URL end.
   9.104 +    virtual bool EndURL();
   9.105 +
   9.106 +    virtual void FieldVanish( const String& rTxt, ww::eField eType );
   9.107 +
   9.108 +    /// Output redlining.
   9.109 +    ///
   9.110 +    /// The common attribute that can be among the run properties.
   9.111 +    virtual void Redline( const SwRedlineData* pRedline );
   9.112 +
   9.113 +    virtual void FormatDrop( const SwTxtNode& rNode, const SwFmtDrop& rSwFmtDrop, USHORT nStyle, ww8::WW8TableNodeInfo::Pointer_t pTextNodeInfo, ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner );
   9.114 +
   9.115 +    /// Output style.
   9.116 +    virtual void ParagraphStyle( USHORT nStyle );
   9.117 +
   9.118 +    virtual void TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.119 +
   9.120 +    virtual void TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.121 +
   9.122 +    virtual void TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.123 +
   9.124 +    virtual void TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.125 +
   9.126 +    virtual void TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.127 +
   9.128 +    virtual void TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.129 +
   9.130 +    virtual void TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.131 +
   9.132 +    virtual void TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.133 +
   9.134 +    virtual void TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.135 +
   9.136 +    virtual void TableNodeInfo( ww8::WW8TableNodeInfo::Pointer_t pNodeInfo );
   9.137 +
   9.138 +    virtual void TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner );
   9.139 +
   9.140 +    virtual void TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.141 +
   9.142 +    virtual void TableRowEnd( sal_uInt32 nDepth );
   9.143 +
   9.144 +    /// Start of the styles table.
   9.145 +    virtual void StartStyles();
   9.146 +
   9.147 +    /// End of the styles table.
   9.148 +    virtual void EndStyles( USHORT nNumberOfStyles );
   9.149 +
   9.150 +    /// Write default style.
   9.151 +    virtual void DefaultStyle( USHORT nStyle );
   9.152 +
   9.153 +    /// Start of a style in the styles table.
   9.154 +    virtual void StartStyle( const String& rName, bool bPapFmt,
   9.155 +            USHORT nBase, USHORT nNext, USHORT nWwId, USHORT nId,
   9.156 +            bool bAutoUpdate );
   9.157 +
   9.158 +    /// End of a style in the styles table.
   9.159 +    virtual void EndStyle();
   9.160 +
   9.161 +    /// Start of (paragraph or run) properties of a style.
   9.162 +    virtual void StartStyleProperties( bool bParProp, USHORT nStyle );
   9.163 +
   9.164 +    /// End of (paragraph or run) properties of a style.
   9.165 +    virtual void EndStyleProperties( bool bParProp );
   9.166 +
   9.167 +    /// Numbering rule and Id.
   9.168 +    virtual void OutlineNumbering( BYTE nLvl, const SwNumFmt &rNFmt, const SwFmt &rFmt );
   9.169 +
   9.170 +    /// Page break
   9.171 +    /// As a paragraph property - the paragraph should be on the next page.
   9.172 +    virtual void PageBreakBefore( bool bBreak );
   9.173 +
   9.174 +    /// Write a section break
   9.175 +    /// msword::ColumnBreak or msword::PageBreak
   9.176 +    virtual void SectionBreak( BYTE nC, const WW8_SepInfo* pSectionInfo = NULL );
   9.177 +
   9.178 +    /// Start of the section properties.
   9.179 +    virtual void StartSection();
   9.180 +
   9.181 +    /// End of the section properties.
   9.182 +    virtual void EndSection();
   9.183 +
   9.184 +    /// Protection of forms.
   9.185 +    virtual void SectionFormProtection( bool bProtected );
   9.186 +
   9.187 +    /// Numbering of the lines in the document.
   9.188 +    virtual void SectionLineNumbering( ULONG nRestartNo, const SwLineNumberInfo& rLnNumInfo );
   9.189 +
   9.190 +    /// Has different headers/footers for the title page.
   9.191 +    virtual void SectionTitlePage();
   9.192 +
   9.193 +    /// Description of the page borders.
   9.194 +    virtual void SectionPageBorders( const SwFrmFmt* pFmt, const SwFrmFmt* pFirstPageFmt );
   9.195 +
   9.196 +    /// Columns populated from right/numbers on the right side?
   9.197 +    virtual void SectionBiDi( bool bBiDi );
   9.198 +
   9.199 +    /// The style of the page numbers.
   9.200 +    ///
   9.201 +    /// nPageRestartNumberr being 0 means no restart.
   9.202 +    virtual void SectionPageNumbering( USHORT nNumType, USHORT nPageRestartNumber );
   9.203 +
   9.204 +    /// The type of breaking.
   9.205 +    virtual void SectionType( BYTE nBreakCode );
   9.206 +
   9.207 +    /// Definition of a numbering instance.
   9.208 +    virtual void NumberingDefinition( USHORT nId, const SwNumRule &rRule );
   9.209 +
   9.210 +    /// Start of the abstract numbering definition instance.
   9.211 +    virtual void StartAbstractNumbering( USHORT nId );
   9.212 +
   9.213 +    /// End of the abstract numbering definition instance.
   9.214 +    virtual void EndAbstractNumbering();
   9.215 +
   9.216 +    /// All the numbering level information.
   9.217 +    virtual void NumberingLevel( BYTE nLevel,
   9.218 +        USHORT nStart,
   9.219 +        USHORT nNumberingType,
   9.220 +        SvxAdjust eAdjust,
   9.221 +        const BYTE *pNumLvlPos,
   9.222 +        BYTE nFollow,
   9.223 +        const wwFont *pFont,
   9.224 +        const SfxItemSet *pOutSet,
   9.225 +        sal_Int16 nIndentAt,
   9.226 +        sal_Int16 nFirstLineIndex,
   9.227 +        sal_Int16 nListTabPos,
   9.228 +        const String &rNumberingString );
   9.229 +
   9.230 +    void WriteField_Impl( const SwField* pFld, ww::eField eType, const String& rFldCmd, BYTE nMode );
   9.231 +    void WriteBookmarks_Impl( std::vector< rtl::OUString >& rStarts, std::vector< rtl::OUString >& rEnds );
   9.232 +    void WriteHeaderFooter_Impl( const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr );
   9.233 +
   9.234 +protected:
   9.235 +    /// Output frames - the implementation.
   9.236 +    virtual void OutputFlyFrame_Impl( const sw::Frame& rFmt, const Point& rNdTopLeft );
   9.237 +
   9.238 +    /// Sfx item Sfx item RES_CHRATR_CASEMAP
   9.239 +    virtual void CharCaseMap( const SvxCaseMapItem& rCaseMap );
   9.240 +
   9.241 +    /// Sfx item Sfx item RES_CHRATR_COLOR
   9.242 +    virtual void CharColor( const SvxColorItem& rColor);
   9.243 +
   9.244 +    /// Sfx item Sfx item RES_CHRATR_CONTOUR
   9.245 +    virtual void CharContour( const SvxContourItem& rContour );
   9.246 +
   9.247 +    /// Sfx item RES_CHRATR_CROSSEDOUT
   9.248 +    virtual void CharCrossedOut( const SvxCrossedOutItem& rCrossedOut );
   9.249 +
   9.250 +    /// Sfx item RES_CHRATR_ESCAPEMENT
   9.251 +    virtual void CharEscapement( const SvxEscapementItem& rEscapement );
   9.252 +
   9.253 +    /// Sfx item RES_CHRATR_FONT
   9.254 +    virtual void CharFont( const SvxFontItem& rFont );
   9.255 +
   9.256 +    /// Sfx item RES_CHRATR_FONTSIZE
   9.257 +    virtual void CharFontSize( const SvxFontHeightItem& rFontSize );
   9.258 +
   9.259 +    /// Sfx item RES_CHRATR_KERNING
   9.260 +    virtual void CharKerning( const SvxKerningItem& rKerning );
   9.261 +
   9.262 +    /// Sfx item RES_CHRATR_LANGUAGE
   9.263 +    virtual void CharLanguage( const SvxLanguageItem& rLanguage );
   9.264 +
   9.265 +    /// Sfx item RES_CHRATR_POSTURE
   9.266 +    virtual void CharPosture( const SvxPostureItem& rPosture );
   9.267 +
   9.268 +    /// Sfx item RES_CHRATR_SHADOWED
   9.269 +    virtual void CharShadow( const SvxShadowedItem& rShadow );
   9.270 +
   9.271 +    /// Sfx item RES_CHRATR_UNDERLINE
   9.272 +    virtual void CharUnderline( const SvxUnderlineItem& rUnderline );
   9.273 +
   9.274 +    /// Sfx item RES_CHRATR_WEIGHT
   9.275 +    virtual void CharWeight( const SvxWeightItem& rWeight );
   9.276 +
   9.277 +    /// Sfx item RES_CHRATR_AUTOKERN
   9.278 +    virtual void CharAutoKern( const SvxAutoKernItem& );
   9.279 +
   9.280 +    /// Sfx item RES_CHRATR_BLINK
   9.281 +    virtual void CharAnimatedText( const SvxBlinkItem& rBlink );
   9.282 +
   9.283 +    /// Sfx item RES_CHRATR_BACKGROUND
   9.284 +    virtual void CharBackground( const SvxBrushItem& rBrush );
   9.285 +
   9.286 +    /// Sfx item RES_CHRATR_CJK_FONT
   9.287 +    virtual void CharFontCJK( const SvxFontItem& rFont );
   9.288 +
   9.289 +    /// Sfx item RES_CHRATR_CJK_FONTSIZE
   9.290 +    virtual void CharFontSizeCJK( const SvxFontHeightItem& rFontSize );
   9.291 +
   9.292 +    /// Sfx item RES_CHRATR_CJK_LANGUAGE
   9.293 +    virtual void CharLanguageCJK( const SvxLanguageItem& rLanguageItem );
   9.294 +
   9.295 +    /// Sfx item RES_CHRATR_CJK_POSTURE
   9.296 +    virtual void CharPostureCJK( const SvxPostureItem& rPosture );
   9.297 +
   9.298 +    /// Sfx item RES_CHRATR_CJK_WEIGHT
   9.299 +    virtual void CharWeightCJK( const SvxWeightItem& rWeight );
   9.300 +
   9.301 +    /// Sfx item RES_CHRATR_CTL_FONT
   9.302 +    virtual void CharFontCTL( const SvxFontItem& rFont );
   9.303 +
   9.304 +    /// Sfx item RES_CHRATR_CTL_FONTSIZE
   9.305 +    virtual void CharFontSizeCTL( const SvxFontHeightItem& rFontSize );
   9.306 +
   9.307 +    /// Sfx item RES_CHRATR_CTL_LANGUAGE
   9.308 +    virtual void CharLanguageCTL( const SvxLanguageItem& rLanguageItem );
   9.309 +
   9.310 +    /// Sfx item RES_CHRATR_CTL_POSTURE
   9.311 +    virtual void CharPostureCTL( const SvxPostureItem& rWeight );
   9.312 +
   9.313 +    /// Sfx item RES_CHRATR_CTL_WEIGHT
   9.314 +    virtual void CharWeightCTL( const SvxWeightItem& rWeight );
   9.315 +
   9.316 +    /// Sfx item RES_CHRATR_ROTATE
   9.317 +    virtual void CharRotate( const SvxCharRotateItem& rRotate );
   9.318 +
   9.319 +    /// Sfx item RES_CHRATR_EMPHASIS_MARK
   9.320 +    virtual void CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark );
   9.321 +
   9.322 +    /// Sfx item RES_CHRATR_TWO_LINES
   9.323 +    virtual void CharTwoLines( const SvxTwoLinesItem& rTwoLines );
   9.324 +
   9.325 +    /// Sfx item RES_CHRATR_SCALEW
   9.326 +    virtual void CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth );
   9.327 +
   9.328 +    /// Sfx item RES_CHRATR_RELIEF
   9.329 +    virtual void CharRelief( const SvxCharReliefItem& rRelief);
   9.330 +
   9.331 +    /// Sfx item RES_CHRATR_HIDDEN
   9.332 +    virtual void CharHidden( const SvxCharHiddenItem& rHidden );
   9.333 +
   9.334 +    /// Sfx item RES_TXTATR_INETFMT
   9.335 +    virtual void TextINetFormat( const SwFmtINetFmt& );
   9.336 +
   9.337 +    /// Sfx item RES_TXTATR_CHARFMT
   9.338 +    virtual void TextCharFormat( const SwFmtCharFmt& );
   9.339 +
   9.340 +    /// Sfx item RES_TXTATR_FTN
   9.341 +    virtual void TextFootnote_Impl( const SwFmtFtn& );
   9.342 +
   9.343 +    /// Sfx item RES_PARATR_LINESPACING
   9.344 +    virtual void ParaLineSpacing_Impl( short nSpace, short nMulti );
   9.345 +
   9.346 +    /// Sfx item RES_PARATR_ADJUST
   9.347 +    virtual void ParaAdjust( const SvxAdjustItem& rAdjust );
   9.348 +
   9.349 +    /// Sfx item RES_PARATR_SPLIT
   9.350 +    virtual void ParaSplit( const SvxFmtSplitItem& rSplit );
   9.351 +
   9.352 +    /// Sfx item RES_PARATR_WIDOWS
   9.353 +    virtual void ParaWidows( const SvxWidowsItem& rWidows );
   9.354 +
   9.355 +    /// Sfx item RES_PARATR_TABSTOP
   9.356 +    virtual void ParaTabStop( const SvxTabStopItem& rTabStop );
   9.357 +
   9.358 +    /// Sfx item RES_PARATR_HYPHENZONE
   9.359 +    virtual void ParaHyphenZone( const SvxHyphenZoneItem& );
   9.360 +
   9.361 +    /// Sfx item RES_PARATR_NUMRULE
   9.362 +    virtual void ParaNumRule_Impl( const SwTxtNode *pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId );
   9.363 +
   9.364 +    /// Sfx item RES_PARATR_SCRIPTSPACE
   9.365 +    virtual void ParaScriptSpace( const SfxBoolItem& );
   9.366 +
   9.367 +    /// Sfx item RES_PARATR_VERTALIGN
   9.368 +    virtual void ParaVerticalAlign( const SvxParaVertAlignItem& rAlign );
   9.369 +
   9.370 +    /// Sfx item RES_PARATR_SNAPTOGRID
   9.371 +    virtual void ParaSnapToGrid( const SvxParaGridItem& );
   9.372 +
   9.373 +    /// Sfx item RES_FRM_SIZE
   9.374 +    virtual void FormatFrameSize( const SwFmtFrmSize& );
   9.375 +
   9.376 +    /// Sfx item RES_PAPER_BIN
   9.377 +    virtual void FormatPaperBin( const SvxPaperBinItem& );
   9.378 +
   9.379 +    /// Sfx item RES_LR_SPACE
   9.380 +    virtual void FormatLRSpace( const SvxLRSpaceItem& rLRSpace );
   9.381 +
   9.382 +    /// Sfx item RES_UL_SPACE
   9.383 +    virtual void FormatULSpace( const SvxULSpaceItem& rULSpace );
   9.384 +
   9.385 +    /// Sfx item RES_SURROUND
   9.386 +    virtual void FormatSurround( const SwFmtSurround& );
   9.387 +
   9.388 +    /// Sfx item RES_VERT_ORIENT
   9.389 +    virtual void FormatVertOrientation( const SwFmtVertOrient& );
   9.390 +
   9.391 +    /// Sfx item RES_HORI_ORIENT
   9.392 +    virtual void FormatHorizOrientation( const SwFmtHoriOrient& );
   9.393 +
   9.394 +    /// Sfx item RES_ANCHOR
   9.395 +    virtual void FormatAnchor( const SwFmtAnchor& );
   9.396 +
   9.397 +    /// Sfx item RES_BACKGROUND
   9.398 +    virtual void FormatBackground( const SvxBrushItem& );
   9.399 +
   9.400 +    /// Sfx item RES_BOX
   9.401 +    virtual void FormatBox( const SvxBoxItem& );
   9.402 +
   9.403 +    /// Sfx item RES_COL
   9.404 +    virtual void FormatColumns_Impl( USHORT nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize );
   9.405 +
   9.406 +    /// Sfx item RES_KEEP
   9.407 +    virtual void FormatKeep( const SvxFmtKeepItem& );
   9.408 +
   9.409 +    /// Sfx item RES_TEXTGRID
   9.410 +    virtual void FormatTextGrid( const SwTextGridItem& );
   9.411 +
   9.412 +    /// Sfx item RES_LINENUMBER
   9.413 +    virtual void FormatLineNumbering( const SwFmtLineNumber& );
   9.414 +
   9.415 +    /// Sfx item RES_FRAMEDIR
   9.416 +    virtual void FormatFrameDirection( const SvxFrameDirectionItem& );
   9.417 +
   9.418 +    /// Write the expanded field
   9.419 +    virtual void WriteExpand( const SwField* pFld );
   9.420 +
   9.421 +    virtual void RefField( const SwField& rFld, const String& rRef );
   9.422 +    virtual void HiddenField( const SwField& rFld );
   9.423 +    virtual void SetField( const SwField& rFld, ww::eField eType, const String& rCmd ); 
   9.424 +    virtual void PostitField( const SwField* pFld );
   9.425 +    virtual bool DropdownField( const SwField* pFld );
   9.426 +
   9.427 +    /// Reference to the export, where to get the data from
   9.428 +    RtfExport &m_rExport;
   9.429 +
   9.430 +private:
   9.431 +
   9.432 +    /// Output graphic fly frames.
   9.433 +    void FlyFrameGraphic( const SwGrfNode& rGrfNode, const Size& rSize );
   9.434 +    void FlyFrameOLE( SwOLENode& rOLENode, const Size& rSize );
   9.435 +    void FlyFrameOLEData( SwOLENode& rOLENode );
   9.436 +
   9.437 +    /*
   9.438 +     * Table methods.
   9.439 +     */
   9.440 +
   9.441 +    void InitTableHelper( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.442 +
   9.443 +    void StartTable( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.444 +
   9.445 +    void StartTableRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.446 +
   9.447 +    void StartTableCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.448 +
   9.449 +    void TableCellProperties( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner );
   9.450 +
   9.451 +    void EndTableCell( );
   9.452 +
   9.453 +    void EndTableRow( );
   9.454 +
   9.455 +    void EndTable();
   9.456 +
   9.457 +    /// End cell, row, and even the entire table if necessary.
   9.458 +    void FinishTableRowCell( ww8::WW8TableNodeInfoInner::Pointer_t pInner, bool bForceEmptyParagraph = false );
   9.459 +
   9.460 +    void WriteTextFootnoteNumStr(const SwFmtFtn& rFootnote);
   9.461 +
   9.462 +    /*
   9.463 +     * Current style name and its ID.
   9.464 +     */
   9.465 +    String m_rStyleName;
   9.466 +    USHORT m_nStyleId;
   9.467 +    /*
   9.468 +     * Current list ID.
   9.469 +     */
   9.470 +    USHORT m_nListId;
   9.471 +    /*
   9.472 +     * This is needed because the call order is: run text, run properties, paragraph properties.
   9.473 +     * What we need is the opposite.
   9.474 +     */
   9.475 +    rtl::OStringBuffer m_aRun;
   9.476 +    rtl::OStringBuffer m_aRunText;
   9.477 +    /*
   9.478 +     * This is written after runs.
   9.479 +     */
   9.480 +    rtl::OStringBuffer m_aAfterRuns;
   9.481 +    /*
   9.482 +     * Same for colors and stylesheets: first we just want to output colors,
   9.483 +     * need to buffer the stylesheet table to output it after the color one.
   9.484 +     */
   9.485 +    rtl::OStringBuffer m_aStylesheet;
   9.486 +    /*
   9.487 +     * This one just holds the style commands in the current style.
   9.488 +     */
   9.489 +    rtl::OStringBuffer m_aStyles;
   9.490 +    /*
   9.491 +     * This is the same as m_aStyles but the conents of it is written last.
   9.492 +     */
   9.493 +    rtl::OStringBuffer m_aStylesEnd;
   9.494 +
   9.495 +    /*
   9.496 +     * We just get a "end of strike" mark at the end of strike, store here what to finish: single or double strike.
   9.497 +     */
   9.498 +    bool m_bStrikeDouble;
   9.499 +
   9.500 +    /*
   9.501 +     * The current table helper.
   9.502 +     */
   9.503 +    SwWriteTable *m_pTableWrt;
   9.504 +
   9.505 +    /*
   9.506 +     * Remember if we are in an open cell, or not.
   9.507 +     */
   9.508 +    bool m_bTableCellOpen;
   9.509 +
   9.510 +    /*
   9.511 +     * Remember the current table depth.
   9.512 +     */
   9.513 +    sal_uInt32 m_nTableDepth;
   9.514 +
   9.515 +    /*
   9.516 +     * Remember if we wrote a \cell or not.
   9.517 +     */
   9.518 +    bool m_bTblAfterCell;
   9.519 +
   9.520 +    /*
   9.521 +     * For late output of row definitions.
   9.522 +     */
   9.523 +    rtl::OStringBuffer m_aRowDefs;
   9.524 +
   9.525 +    /*
   9.526 +     * Is a column break needed after the next \par?
   9.527 +     */
   9.528 +    bool m_nColBreakNeeded;
   9.529 +
   9.530 +    /*
   9.531 +     * If section breaks should be buffered to m_aSectionBreaks
   9.532 +     */
   9.533 +    bool m_bBufferSectionBreaks;
   9.534 +    rtl::OStringBuffer m_aSectionBreaks;
   9.535 +
   9.536 +    /*
   9.537 +     * If section headers (and footers) should be buffered to
   9.538 +     * m_aSectionHeaders.
   9.539 +     */
   9.540 +    bool m_bBufferSectionHeaders;
   9.541 +    rtl::OStringBuffer m_aSectionHeaders;
   9.542 +
   9.543 +public:
   9.544 +    RtfAttributeOutput( RtfExport &rExport );
   9.545 +
   9.546 +    virtual ~RtfAttributeOutput();
   9.547 +
   9.548 +    /// Return the right export class.
   9.549 +    virtual MSWordExportBase& GetExport();
   9.550 +
   9.551 +    rtl::OStringBuffer m_aTabStop;
   9.552 +
   9.553 +    // These are used by wwFont::WriteRtf()
   9.554 +    /// Start the font.
   9.555 +    void StartFont( const String& rFamilyName ) const;
   9.556 +
   9.557 +    /// End the font.
   9.558 +    void EndFont() const;
   9.559 +
   9.560 +    /// Alternate name for the font.
   9.561 +    void FontAlternateName( const String& rName ) const;
   9.562 +
   9.563 +    /// Font charset.
   9.564 +    void FontCharset( sal_uInt8 nCharSet ) const;
   9.565 +
   9.566 +    /// Font family.
   9.567 +    void FontFamilyType( FontFamily eFamily, const wwFont &rFont ) const;
   9.568 +
   9.569 +    /// Font pitch.
   9.570 +    void FontPitchType( FontPitch ePitch ) const;
   9.571 +};
   9.572 +
   9.573 +#endif // _RTFATTRIBUTEOUTPUT_HXX_
   9.574 +
   9.575 +/* vi:set shiftwidth=4 expandtab: */
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/sw/source/filter/ww8/rtfexport.cxx	Thu Jul 29 22:01:25 2010 +0200
    10.3 @@ -0,0 +1,1235 @@
    10.4 +/*************************************************************************
    10.5 + *
    10.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    10.7 + *
    10.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    10.9 + * Copyright 2010 Miklos Vajna.
   10.10 + *
   10.11 + * OpenOffice.org - a multi-platform office productivity suite
   10.12 + *
   10.13 + * This file is part of OpenOffice.org.
   10.14 + *
   10.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   10.16 + * it under the terms of the GNU Lesser General Public License version 3
   10.17 + * only, as published by the Free Software Foundation.
   10.18 + *
   10.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   10.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   10.22 + * GNU Lesser General Public License version 3 for more details
   10.23 + * (a copy is included in the LICENSE file that accompanied this code).
   10.24 + *
   10.25 + * You should have received a copy of the GNU Lesser General Public License
   10.26 + * version 3 along with OpenOffice.org.  If not, see
   10.27 + * <http://www.openoffice.org/license.html>
   10.28 + * for a copy of the LGPLv3 License.
   10.29 + *
   10.30 + ************************************************************************/
   10.31 +
   10.32 +#include "rtfexport.hxx"
   10.33 +#include "rtfexportfilter.hxx"
   10.34 +#include "rtfsdrexport.hxx"
   10.35 +
   10.36 +#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
   10.37 +#include <com/sun/star/document/XDocumentProperties.hpp>
   10.38 +#include <com/sun/star/i18n/ScriptType.hdl>
   10.39 +#include <com/sun/star/frame/XModel.hpp>
   10.40 +
   10.41 +#include <map>
   10.42 +#include <algorithm>
   10.43 +#include <iostream>
   10.44 +#include <iomanip>
   10.45 +#include <string>
   10.46 +#include <sstream>
   10.47 +
   10.48 +#include <IMark.hxx>
   10.49 +#include <docsh.hxx>
   10.50 +#include <ndtxt.hxx>
   10.51 +#include <wrtww8.hxx>
   10.52 +#include <fltini.hxx>
   10.53 +#include <fmtline.hxx>
   10.54 +#include <fmtpdsc.hxx>
   10.55 +#include <frmfmt.hxx>
   10.56 +#include <section.hxx>
   10.57 +#include <pagedesc.hxx>
   10.58 +#include <swtable.hxx>
   10.59 +#include <fmtfsize.hxx>
   10.60 +#include <frmatr.hxx>
   10.61 +#include <ftninfo.hxx>
   10.62 +#include <fmthdft.hxx>
   10.63 +#include <svx/fontitem.hxx>
   10.64 +#include <svx/colritem.hxx>
   10.65 +#include <svx/udlnitem.hxx>
   10.66 +#include <svx/boxitem.hxx>
   10.67 +#include <svx/brshitem.hxx>
   10.68 +#include <svx/shaditem.hxx>
   10.69 +#include <svx/lrspitem.hxx>
   10.70 +#include <svx/ulspitem.hxx>
   10.71 +#include <svx/paperinf.hxx>
   10.72 +#include <svx/protitem.hxx>
   10.73 +
   10.74 +#include <docary.hxx>
   10.75 +#include <numrule.hxx>
   10.76 +#include <charfmt.hxx>
   10.77 +#include <lineinfo.hxx>
   10.78 +#include <swmodule.hxx>
   10.79 +
   10.80 +#include "ww8par.hxx"
   10.81 +#include "ww8scan.hxx"
   10.82 +
   10.83 +#include <comphelper/string.hxx>
   10.84 +#include <rtl/ustrbuf.hxx>
   10.85 +#include <vcl/font.hxx>
   10.86 +#include <svtools/rtfkeywd.hxx>
   10.87 +#include <unotools/configmgr.hxx>
   10.88 +
   10.89 +using namespace ::comphelper;
   10.90 +using namespace ::com::sun::star;
   10.91 +
   10.92 +using rtl::OString;
   10.93 +using rtl::OUString;
   10.94 +using rtl::OStringBuffer;
   10.95 +using rtl::OUStringBuffer;
   10.96 +
   10.97 +using sw::mark::IMark;
   10.98 +
   10.99 +#if defined(UNX)
  10.100 +const sal_Char RtfExport::sNewLine = '\012';
  10.101 +#else
  10.102 +const sal_Char __FAR_DATA RtfExport::sNewLine[] = "\015\012";
  10.103 +#endif
  10.104 +
  10.105 +// the default text encoding for the export, if it doesn't fit unicode will
  10.106 +// be used
  10.107 +#define DEF_ENCODING            RTL_TEXTENCODING_ASCII_US
  10.108 +
  10.109 +AttributeOutputBase& RtfExport::AttrOutput() const
  10.110 +{
  10.111 +    return *m_pAttrOutput;
  10.112 +}
  10.113 +
  10.114 +MSWordSections& RtfExport::Sections() const
  10.115 +{
  10.116 +    return *m_pSections;
  10.117 +}
  10.118 +
  10.119 +RtfSdrExport& RtfExport::SdrExporter() const
  10.120 +{
  10.121 +    return *m_pSdrExport;
  10.122 +}
  10.123 +
  10.124 +bool RtfExport::CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich )
  10.125 +{
  10.126 +    // FIXME is this actually true for rtf? - this is copied from DOCX
  10.127 +    if ( nScript == i18n::ScriptType::ASIAN )
  10.128 +    {
  10.129 +        // for asian in ww8, there is only one fontsize
  10.130 +        // and one fontstyle (posture/weight)
  10.131 +        switch ( nWhich )
  10.132 +        {
  10.133 +            case RES_CHRATR_FONTSIZE:
  10.134 +            case RES_CHRATR_POSTURE:
  10.135 +            case RES_CHRATR_WEIGHT:
  10.136 +                return false;
  10.137 +            default:
  10.138 +                break;
  10.139 +        }
  10.140 +    }
  10.141 +    else if ( nScript != i18n::ScriptType::COMPLEX )
  10.142 +    {
  10.143 +        // for western in ww8, there is only one fontsize
  10.144 +        // and one fontstyle (posture/weight)
  10.145 +        switch ( nWhich )
  10.146 +        {
  10.147 +            case RES_CHRATR_CJK_FONTSIZE:
  10.148 +            case RES_CHRATR_CJK_POSTURE:
  10.149 +            case RES_CHRATR_CJK_WEIGHT:
  10.150 +                return false;
  10.151 +            default:
  10.152 +                break;
  10.153 +        }
  10.154 +    }
  10.155 +    return true;
  10.156 +}
  10.157 +
  10.158 +void RtfExport::AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen )
  10.159 +{
  10.160 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.161 +
  10.162 +    std::vector< OUString > aStarts;
  10.163 +    std::vector< OUString > aEnds;
  10.164 +
  10.165 +    IMarkVector aMarks;
  10.166 +    if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarks ) )
  10.167 +    {
  10.168 +        for ( IMarkVector::const_iterator it = aMarks.begin(), end = aMarks.end();
  10.169 +                it < end; ++it )
  10.170 +        {
  10.171 +            IMark* pMark = (*it);
  10.172 +            xub_StrLen nStart = pMark->GetMarkStart().nContent.GetIndex();
  10.173 +            xub_StrLen nEnd = pMark->GetMarkEnd().nContent.GetIndex();
  10.174 +
  10.175 +            if ( nStart == nAktPos )
  10.176 +                aStarts.push_back( pMark->GetName() );
  10.177 +
  10.178 +            if ( nEnd == nAktPos )
  10.179 +                aEnds.push_back( pMark->GetName() );
  10.180 +        }
  10.181 +    }
  10.182 +
  10.183 +    m_pAttrOutput->WriteBookmarks_Impl( aStarts, aEnds );
  10.184 +}
  10.185 +
  10.186 +void RtfExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ )
  10.187 +{
  10.188 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.189 +
  10.190 +    std::vector<OUString> aStarts;
  10.191 +    std::vector<OUString> aEnds;
  10.192 +
  10.193 +    aStarts.push_back(rName);
  10.194 +    aEnds.push_back(rName);
  10.195 +
  10.196 +    m_pAttrOutput->WriteBookmarks_Impl(aStarts, aEnds);
  10.197 +}
  10.198 +
  10.199 +void RtfExport::WriteChar( sal_Unicode )
  10.200 +{
  10.201 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.202 +
  10.203 +    /* WriteChar() has nothing to do for rtf. */
  10.204 +}
  10.205 +
  10.206 +static bool IsExportNumRule( const SwNumRule& rRule, BYTE* pEnd = 0 )
  10.207 +{
  10.208 +    BYTE nEnd = MAXLEVEL;
  10.209 +    while( nEnd-- && !rRule.GetNumFmt( nEnd ))
  10.210 +        ;
  10.211 +    ++nEnd;
  10.212 +
  10.213 +    const SwNumFmt* pNFmt;
  10.214 +    BYTE nLvl;
  10.215 +
  10.216 +    for( nLvl = 0; nLvl < nEnd; ++nLvl )
  10.217 +        if( SVX_NUM_NUMBER_NONE != ( pNFmt = &rRule.Get( nLvl ))
  10.218 +                ->GetNumberingType() || pNFmt->GetPrefix().Len() ||
  10.219 +                (pNFmt->GetSuffix().Len() && pNFmt->GetSuffix() != aDotStr ))
  10.220 +            break;
  10.221 +
  10.222 +    if( pEnd )
  10.223 +        *pEnd = nEnd;
  10.224 +    return nLvl != nEnd;
  10.225 +}
  10.226 +
  10.227 +void RtfExport::BuildNumbering()
  10.228 +{
  10.229 +    const SwNumRuleTbl& rListTbl = pDoc->GetNumRuleTbl();
  10.230 +
  10.231 +    for( USHORT n = rListTbl.Count()+1; n; )
  10.232 +    {
  10.233 +        SwNumRule* pRule;
  10.234 +        --n;
  10.235 +        if( n == rListTbl.Count() )
  10.236 +            pRule = (SwNumRule*)pDoc->GetOutlineNumRule();
  10.237 +        else
  10.238 +        {
  10.239 +            pRule = rListTbl[ n ];
  10.240 +            if( !pDoc->IsUsed( *pRule ))
  10.241 +                continue;
  10.242 +        }
  10.243 +
  10.244 +        if( IsExportNumRule( *pRule ))
  10.245 +            GetId( *pRule );
  10.246 +    }
  10.247 +}
  10.248 +
  10.249 +void RtfExport::WriteNumbering()
  10.250 +{
  10.251 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
  10.252 +
  10.253 +    if ( !pUsedNumTbl )
  10.254 +        return; // no numbering is used
  10.255 +
  10.256 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_LISTTABLE;
  10.257 +    AbstractNumberingDefinitions();
  10.258 +    Strm() << '}';
  10.259 +
  10.260 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_LISTOVERRIDETABLE;
  10.261 +    NumberingDefinitions();
  10.262 +    Strm() << '}';
  10.263 +
  10.264 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
  10.265 +}
  10.266 +
  10.267 +void RtfExport::WriteRevTab()
  10.268 +{
  10.269 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.270 +
  10.271 +    int nRevAuthors = pDoc->GetRedlineTbl().Count();
  10.272 +
  10.273 +    if (nRevAuthors < 1)
  10.274 +        return;
  10.275 +
  10.276 +    // RTF always seems to use Unknown as the default first entry
  10.277 +    String sUnknown(RTL_CONSTASCII_USTRINGPARAM("Unknown"));
  10.278 +    GetRedline(sUnknown);
  10.279 +
  10.280 +    for( USHORT i = 0; i < pDoc->GetRedlineTbl().Count(); ++i )
  10.281 +    {
  10.282 +        const SwRedline* pRedl = pDoc->GetRedlineTbl()[ i ];
  10.283 +
  10.284 +        GetRedline(SW_MOD()->GetRedlineAuthor(pRedl->GetAuthor()));
  10.285 +    }
  10.286 +
  10.287 +    // Now write the table
  10.288 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_REVTBL << ' ';
  10.289 +    for(std::map<String,USHORT>::iterator aIter = m_aRedlineTbl.begin(); aIter != m_aRedlineTbl.end(); ++aIter)
  10.290 +        Strm() << '{' << OutString((*aIter).first, eDefaultEncoding) << ";}";
  10.291 +    Strm() << '}' << sNewLine;
  10.292 +}
  10.293 +
  10.294 +void RtfExport::WriteHeadersFooters( BYTE nHeadFootFlags,
  10.295 +        const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, BYTE /*nBreakCode*/ )
  10.296 +{
  10.297 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.298 +
  10.299 +    // headers
  10.300 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_EVEN )
  10.301 +        WriteHeaderFooter( rLeftFmt, true, OOO_STRING_SVTOOLS_RTF_HEADERL );
  10.302 +
  10.303 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_ODD )
  10.304 +        WriteHeaderFooter( rFmt, true, OOO_STRING_SVTOOLS_RTF_HEADER );
  10.305 +
  10.306 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_HEADER_FIRST )
  10.307 +        WriteHeaderFooter( rFirstPageFmt, true, OOO_STRING_SVTOOLS_RTF_HEADERF );
  10.308 +
  10.309 +    // footers
  10.310 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_EVEN )
  10.311 +        WriteHeaderFooter( rLeftFmt, false, OOO_STRING_SVTOOLS_RTF_FOOTERL );
  10.312 +
  10.313 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_ODD )
  10.314 +        WriteHeaderFooter( rFmt, false, OOO_STRING_SVTOOLS_RTF_FOOTER );
  10.315 +
  10.316 +    if ( nHeadFootFlags & nsHdFtFlags::WW8_FOOTER_FIRST )
  10.317 +        WriteHeaderFooter( rFirstPageFmt, false, OOO_STRING_SVTOOLS_RTF_FOOTERF );
  10.318 +}
  10.319 +
  10.320 +void RtfExport::OutputField( const SwField* pFld, ww::eField eFldType, const String& rFldCmd, BYTE nMode )
  10.321 +{
  10.322 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.323 +
  10.324 +    m_pAttrOutput->WriteField_Impl( pFld, eFldType, rFldCmd, nMode );
  10.325 +}
  10.326 +
  10.327 +void RtfExport::WriteFormData( const ::sw::mark::IFieldmark& /*rFieldmark*/ )
  10.328 +{
  10.329 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  10.330 +}
  10.331 +
  10.332 +void RtfExport::WriteHyperlinkData( const ::sw::mark::IFieldmark& /*rFieldmark*/ )
  10.333 +{
  10.334 +    OSL_TRACE("TODO: %s", __PRETTY_FUNCTION__);
  10.335 +}
  10.336 +
  10.337 +void RtfExport::DoComboBox(const rtl::OUString& /*rName*/,
  10.338 +                             const rtl::OUString& /*rHelp*/,
  10.339 +                             const rtl::OUString& /*rToolTip*/,
  10.340 +                             const rtl::OUString& /*rSelected*/,
  10.341 +                             uno::Sequence<rtl::OUString>& /*rListItems*/)
  10.342 +{
  10.343 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.344 +
  10.345 +    // this is handled in RtfAttributeOutput::OutputFlyFrame_Impl
  10.346 +}
  10.347 +
  10.348 +void RtfExport::DoFormText(const SwInputField* /*pFld*/)
  10.349 +{
  10.350 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.351 +
  10.352 +    // this is hanled in RtfAttributeOutput::OutputFlyFrame_Impl
  10.353 +}
  10.354 +
  10.355 +ULONG RtfExport::ReplaceCr( BYTE )
  10.356 +{
  10.357 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.358 +
  10.359 +    // Completely unused for Rtf export... only here for code sharing 
  10.360 +    // purpose with binary export
  10.361 +
  10.362 +    return 0;
  10.363 +}
  10.364 +
  10.365 +void RtfExport::WriteFonts()
  10.366 +{
  10.367 +    Strm() << sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_FONTTBL;
  10.368 +    maFontHelper.WriteFontTable( *m_pAttrOutput );
  10.369 +    Strm() << '}';
  10.370 +}
  10.371 +
  10.372 +void RtfExport::WriteStyles()
  10.373 +{
  10.374 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
  10.375 +    pStyles->OutputStylesTable();
  10.376 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
  10.377 +}
  10.378 +
  10.379 +void RtfExport::WriteMainText()
  10.380 +{
  10.381 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
  10.382 +    WriteText();
  10.383 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
  10.384 +}
  10.385 +
  10.386 +void RtfExport::WriteInfo()
  10.387 +{
  10.388 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.389 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_INFO;
  10.390 +
  10.391 +    SwDocShell *pDocShell(pDoc->GetDocShell());
  10.392 +    uno::Reference<document::XDocumentProperties> xDocProps;
  10.393 +    if (pDocShell) {
  10.394 +        uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
  10.395 +                pDocShell->GetModel(), uno::UNO_QUERY);
  10.396 +        xDocProps.set(xDPS->getDocumentProperties());
  10.397 +    }
  10.398 +
  10.399 +    if (xDocProps.is()) {
  10.400 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_TITLE, xDocProps->getTitle());
  10.401 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_SUBJECT, xDocProps->getSubject());
  10.402 +
  10.403 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_KEYWORDS,
  10.404 +                ::comphelper::string::convertCommaSeparated(xDocProps->getKeywords()));
  10.405 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_DOCCOMM, xDocProps->getDescription());
  10.406 +
  10.407 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_AUTHOR, xDocProps->getAuthor());
  10.408 +        OutDateTime(OOO_STRING_SVTOOLS_RTF_CREATIM, xDocProps->getCreationDate());
  10.409 +
  10.410 +        OutUnicode(OOO_STRING_SVTOOLS_RTF_AUTHOR,xDocProps->getModifiedBy());
  10.411 +        OutDateTime(OOO_STRING_SVTOOLS_RTF_REVTIM, xDocProps->getModificationDate());
  10.412 +
  10.413 +        OutDateTime(OOO_STRING_SVTOOLS_RTF_PRINTIM, xDocProps->getPrintDate());
  10.414 +    }
  10.415 +
  10.416 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_COMMENT << " ";
  10.417 +    OUString sProduct;
  10.418 +    utl::ConfigManager::GetDirectConfigProperty(utl::ConfigManager::PRODUCTNAME) >>= sProduct;
  10.419 +    Strm() << OUStringToOString( sProduct, eCurrentEncoding) << "}{" << OOO_STRING_SVTOOLS_RTF_VERN;
  10.420 +    OutULong( SUPD*10 ) << '}';
  10.421 +    Strm() << '}';
  10.422 +}
  10.423 +
  10.424 +void RtfExport::WritePageDescTable()
  10.425 +{
  10.426 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.427 +
  10.428 +    // Write page descriptions (page styles)
  10.429 +    USHORT nSize = pDoc->GetPageDescCnt();
  10.430 +    if( !nSize )
  10.431 +        return;
  10.432 +
  10.433 +    Strm() << sNewLine;        // a separator
  10.434 +    bOutPageDescs = TRUE;
  10.435 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_PGDSCTBL;
  10.436 +    for( USHORT n = 0; n < nSize; ++n )
  10.437 +    {
  10.438 +        const SwPageDesc& rPageDesc =
  10.439 +            const_cast<const SwDoc*>(pDoc)->GetPageDesc( n );
  10.440 +
  10.441 +        Strm() << sNewLine << '{' << OOO_STRING_SVTOOLS_RTF_PGDSC;
  10.442 +        OutULong( n ) << OOO_STRING_SVTOOLS_RTF_PGDSCUSE;
  10.443 +        OutULong( rPageDesc.ReadUseOn() );
  10.444 +
  10.445 +        OutPageDescription( rPageDesc, FALSE, FALSE );
  10.446 +
  10.447 +        // search for the next page description
  10.448 +        USHORT i = nSize;
  10.449 +        while( i  )
  10.450 +            if( rPageDesc.GetFollow() ==
  10.451 +                    &const_cast<const SwDoc *>(pDoc)->GetPageDesc( --i ) )
  10.452 +                break;
  10.453 +        Strm() << OOO_STRING_SVTOOLS_RTF_PGDSCNXT;
  10.454 +        OutULong( i ) << ' ';
  10.455 +        Strm() << OutString( rPageDesc.GetName(), eDefaultEncoding) << ";}";
  10.456 +    }
  10.457 +    Strm() << '}' << sNewLine;
  10.458 +    bOutPageDescs = FALSE;
  10.459 +}
  10.460 +
  10.461 +void RtfExport::ExportDocument_Impl()
  10.462 +{
  10.463 +#ifdef DEBUG
  10.464 +    // MSWordExportBase::WriteText and others write debug messages to std::clog
  10.465 +    // which is not interesting while debugging RtfExport
  10.466 +    std::ostringstream aOss;
  10.467 +    std::streambuf *pOldBuf = std::clog.rdbuf(aOss.rdbuf());
  10.468 +#endif
  10.469 +
  10.470 +    // Make the header
  10.471 +    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_RTF << '1'
  10.472 +        << OOO_STRING_SVTOOLS_RTF_ANSI;
  10.473 +    Strm() << OOO_STRING_SVTOOLS_RTF_DEFF;
  10.474 +    OutULong( maFontHelper.GetId( (SvxFontItem&)pDoc->GetAttrPool().GetDefaultItem(
  10.475 +                    RES_CHRATR_FONT ) ));
  10.476 +    // If this not exist, MS don't understand our ansi characters (0x80-0xff).
  10.477 +    Strm() << "\\adeflang1025";
  10.478 +
  10.479 +    // Font table
  10.480 +    WriteFonts();
  10.481 +
  10.482 +    pStyles = new MSWordStyles( *this );
  10.483 +    // Color and stylesheet table
  10.484 +    WriteStyles();
  10.485 +
  10.486 +    // List table
  10.487 +    BuildNumbering();
  10.488 +    WriteNumbering();
  10.489 +
  10.490 +    WriteRevTab();
  10.491 +
  10.492 +    WriteInfo();
  10.493 +    // Default TabSize
  10.494 +    Strm() << m_pAttrOutput->m_aTabStop.makeStringAndClear() << sNewLine;
  10.495 +    // Page description
  10.496 +    WritePageDescTable();
  10.497 +
  10.498 +    // Enable form protection by default if needed, as there is no switch to
  10.499 +    // enable it on a per-section basis. OTOH don't always enable it as it
  10.500 +    // breaks moving of drawings - so write it only in case there is really a
  10.501 +    // protected section in the document.
  10.502 +    {
  10.503 +        const SfxItemPool& rPool = pDoc->GetAttrPool();
  10.504 +        USHORT nMaxItem = rPool.GetItemCount(RES_PROTECT);
  10.505 +        for( USHORT n = 0; n < nMaxItem; ++n )
  10.506 +        {
  10.507 +            const SvxProtectItem* pProtect = (const SvxProtectItem*)rPool.GetItem(RES_PROTECT, n);
  10.508 +            if (pProtect && pProtect->IsCntntProtected())
  10.509 +            {
  10.510 +                Strm() << OOO_STRING_SVTOOLS_RTF_FORMPROT;
  10.511 +                break;
  10.512 +            }
  10.513 +        }
  10.514 +    }
  10.515 +
  10.516 +    // enable form field shading
  10.517 +    Strm() << OOO_STRING_SVTOOLS_RTF_FORMSHADE;
  10.518 +
  10.519 +    // size and empty margins of the page
  10.520 +    if( pDoc->GetPageDescCnt() )
  10.521 +    {
  10.522 +        //JP 06.04.99: Bug 64361 - Seeking the first SwFmtPageDesc. If
  10.523 +        //				no set, the default is valid
  10.524 +        const SwFmtPageDesc* pSttPgDsc = 0;
  10.525 +        {
  10.526 +            const SwNode& rSttNd = *pDoc->GetNodes()[
  10.527 +                        pDoc->GetNodes().GetEndOfExtras().GetIndex() + 2 ];
  10.528 +            const SfxItemSet* pSet = 0;
  10.529 +
  10.530 +            if( rSttNd.IsCntntNode() )
  10.531 +                pSet = &rSttNd.GetCntntNode()->GetSwAttrSet();
  10.532 +            else if( rSttNd.IsTableNode() )
  10.533 +                pSet = &rSttNd.GetTableNode()->GetTable().
  10.534 +                            GetFrmFmt()->GetAttrSet();
  10.535 +            else if( rSttNd.IsSectionNode() )
  10.536 +                pSet = &rSttNd.GetSectionNode()->GetSection().
  10.537 +                            GetFmt()->GetAttrSet();
  10.538 +
  10.539 +            if( pSet )
  10.540 +            {
  10.541 +                USHORT nPosInDoc;
  10.542 +                pSttPgDsc = (SwFmtPageDesc*)&pSet->Get( RES_PAGEDESC );
  10.543 +                if( !pSttPgDsc->GetPageDesc() )
  10.544 +                    pSttPgDsc = 0;
  10.545 +                else if( pDoc->FindPageDescByName( pSttPgDsc->
  10.546 +                                    GetPageDesc()->GetName(), &nPosInDoc ))
  10.547 +                {
  10.548 +                    Strm() << '{' << OOO_STRING_SVTOOLS_RTF_IGNORE << OOO_STRING_SVTOOLS_RTF_PGDSCNO;
  10.549 +                    OutULong( nPosInDoc ) << '}';
  10.550 +                }
  10.551 +            }
  10.552 +        }
  10.553 +        const SwPageDesc& rPageDesc = pSttPgDsc ? *pSttPgDsc->GetPageDesc()
  10.554 +            : const_cast<const SwDoc *>(pDoc)->GetPageDesc( 0 );
  10.555 +        const SwFrmFmt &rFmtPage = rPageDesc.GetMaster();
  10.556 +
  10.557 +        {
  10.558 +            if( rPageDesc.GetLandscape() )
  10.559 +                Strm() << OOO_STRING_SVTOOLS_RTF_LANDSCAPE;
  10.560 +
  10.561 +            const SwFmtFrmSize& rSz = rFmtPage.GetFrmSize();
  10.562 +            // Clipboard document is always created without a printer, then
  10.563 +            // the size will be always LONG_MAX! Solution then is to use A4
  10.564 +            if( LONG_MAX == rSz.GetHeight() || LONG_MAX == rSz.GetWidth() )
  10.565 +            {
  10.566 +                Strm() << OOO_STRING_SVTOOLS_RTF_PAPERH;
  10.567 +                Size a4 = SvxPaperInfo::GetPaperSize(PAPER_A4);
  10.568 +                OutULong( a4.Height() ) << OOO_STRING_SVTOOLS_RTF_PAPERW;
  10.569 +                OutULong( a4.Width() );
  10.570 +            }
  10.571 +            else
  10.572 +            {
  10.573 +                Strm() << OOO_STRING_SVTOOLS_RTF_PAPERH;
  10.574 +                OutULong( rSz.GetHeight() ) << OOO_STRING_SVTOOLS_RTF_PAPERW;
  10.575 +                OutULong( rSz.GetWidth() );
  10.576 +            }
  10.577 +        }
  10.578 +
  10.579 +        {
  10.580 +            const SvxLRSpaceItem& rLR = rFmtPage.GetLRSpace();
  10.581 +            Strm() << OOO_STRING_SVTOOLS_RTF_MARGL;
  10.582 +            OutLong( rLR.GetLeft() ) << OOO_STRING_SVTOOLS_RTF_MARGR;
  10.583 +            OutLong( rLR.GetRight() );
  10.584 +        }
  10.585 +
  10.586 +        {
  10.587 +            const SvxULSpaceItem& rUL = rFmtPage.GetULSpace();
  10.588 +            Strm() << OOO_STRING_SVTOOLS_RTF_MARGT;
  10.589 +            OutLong( rUL.GetUpper() ) << OOO_STRING_SVTOOLS_RTF_MARGB;
  10.590 +            OutLong( rUL.GetLower() );
  10.591 +        }
  10.592 +
  10.593 +        Strm() << OOO_STRING_SVTOOLS_RTF_SECTD << OOO_STRING_SVTOOLS_RTF_SBKNONE;
  10.594 +        // All sections are unlocked by default
  10.595 +        Strm() << OOO_STRING_SVTOOLS_RTF_SECTUNLOCKED;
  10.596 +        OutLong(1);
  10.597 +        OutPageDescription( rPageDesc, FALSE, TRUE );	// Changed bCheckForFirstPage to TRUE so headers
  10.598 +                                                            // following title page are correctly added - i13107
  10.599 +        if( pSttPgDsc )
  10.600 +        {
  10.601 +            pAktPageDesc = &rPageDesc;
  10.602 +        }
  10.603 +    }
  10.604 +
  10.605 +    // line numbering
  10.606 +    const SwLineNumberInfo& rLnNumInfo = pDoc->GetLineNumberInfo();
  10.607 +    if ( rLnNumInfo.IsPaintLineNumbers() )
  10.608 +        AttrOutput().SectionLineNumbering( 0, rLnNumInfo );
  10.609 +
  10.610 +    {
  10.611 +        // write the footnotes and endnotes-out Info
  10.612 +        const SwFtnInfo& rFtnInfo = pDoc->GetFtnInfo();
  10.613 +
  10.614 +        const char* pOut = FTNPOS_CHAPTER == rFtnInfo.ePos
  10.615 +                            ? OOO_STRING_SVTOOLS_RTF_ENDDOC
  10.616 +                            : OOO_STRING_SVTOOLS_RTF_FTNBJ;
  10.617 +        Strm() << pOut << OOO_STRING_SVTOOLS_RTF_FTNSTART;
  10.618 +        OutLong( rFtnInfo.nFtnOffset + 1 );
  10.619 +
  10.620 +        switch( rFtnInfo.eNum )
  10.621 +        {
  10.622 +            case FTNNUM_PAGE:		pOut = OOO_STRING_SVTOOLS_RTF_FTNRSTPG;	break;
  10.623 +            case FTNNUM_DOC:		pOut = OOO_STRING_SVTOOLS_RTF_FTNRSTCONT;	break;
  10.624 +            // case FTNNUM_CHAPTER:
  10.625 +            default:				pOut = OOO_STRING_SVTOOLS_RTF_FTNRESTART;	break;
  10.626 +        }
  10.627 +        Strm() << pOut;
  10.628 +
  10.629 +        switch( rFtnInfo.aFmt.GetNumberingType() )
  10.630 +        {
  10.631 +            case SVX_NUM_CHARS_LOWER_LETTER:
  10.632 +            case SVX_NUM_CHARS_LOWER_LETTER_N:	pOut = OOO_STRING_SVTOOLS_RTF_FTNNALC; 	break;
  10.633 +            case SVX_NUM_CHARS_UPPER_LETTER:
  10.634 +            case SVX_NUM_CHARS_UPPER_LETTER_N:	pOut = OOO_STRING_SVTOOLS_RTF_FTNNAUC; 	break;
  10.635 +            case SVX_NUM_ROMAN_LOWER:			pOut = OOO_STRING_SVTOOLS_RTF_FTNNRLC; 	break;
  10.636 +            case SVX_NUM_ROMAN_UPPER:			pOut = OOO_STRING_SVTOOLS_RTF_FTNNRUC; 	break;
  10.637 +            case SVX_NUM_CHAR_SPECIAL:			pOut = OOO_STRING_SVTOOLS_RTF_FTNNCHI;	break;
  10.638 +            // case SVX_NUM_ARABIC:
  10.639 +            default:					pOut = OOO_STRING_SVTOOLS_RTF_FTNNAR;		break;
  10.640 +        }
  10.641 +        Strm() << pOut;
  10.642 +
  10.643 +
  10.644 +        const SwEndNoteInfo& rEndNoteInfo = pDoc->GetEndNoteInfo();
  10.645 +
  10.646 +        Strm() << OOO_STRING_SVTOOLS_RTF_AENDDOC << OOO_STRING_SVTOOLS_RTF_AFTNRSTCONT
  10.647 +               << OOO_STRING_SVTOOLS_RTF_AFTNSTART;
  10.648 +        OutLong( rEndNoteInfo.nFtnOffset + 1 );
  10.649 +
  10.650 +        switch( rEndNoteInfo.aFmt.GetNumberingType() )
  10.651 +        {
  10.652 +            case SVX_NUM_CHARS_LOWER_LETTER:
  10.653 +            case SVX_NUM_CHARS_LOWER_LETTER_N:	pOut = OOO_STRING_SVTOOLS_RTF_AFTNNALC;	break;
  10.654 +            case SVX_NUM_CHARS_UPPER_LETTER:
  10.655 +            case SVX_NUM_CHARS_UPPER_LETTER_N:	pOut = OOO_STRING_SVTOOLS_RTF_AFTNNAUC;	break;
  10.656 +            case SVX_NUM_ROMAN_LOWER:			pOut = OOO_STRING_SVTOOLS_RTF_AFTNNRLC;	break;
  10.657 +            case SVX_NUM_ROMAN_UPPER:			pOut = OOO_STRING_SVTOOLS_RTF_AFTNNRUC;	break;
  10.658 +            case SVX_NUM_CHAR_SPECIAL:			pOut = OOO_STRING_SVTOOLS_RTF_AFTNNCHI;	break;
  10.659 +            // case SVX_NUM_ARABIC:
  10.660 +            default:					pOut = OOO_STRING_SVTOOLS_RTF_AFTNNAR;	break;
  10.661 +        }
  10.662 +        Strm() << pOut;
  10.663 +    }
  10.664 +
  10.665 +    Strm() << sNewLine;
  10.666 +
  10.667 +    // Init sections
  10.668 +    m_pSections = new MSWordSections( *this );
  10.669 +
  10.670 +    WriteMainText();
  10.671 +
  10.672 +    Strm() << '}';
  10.673 +
  10.674 +#ifdef DEBUG
  10.675 +    std::clog.rdbuf(pOldBuf);
  10.676 +#endif
  10.677 +}
  10.678 +
  10.679 +void RtfExport::PrepareNewPageDesc( const SfxItemSet* pSet,
  10.680 +        const SwNode& rNd, const SwFmtPageDesc* pNewPgDescFmt,
  10.681 +        const SwPageDesc* pNewPgDesc )
  10.682 +{
  10.683 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.684 +    const SwSectionFmt* pFmt = GetSectionFormat( rNd );
  10.685 +    const ULONG nLnNm = GetSectionLineNo( pSet, rNd );
  10.686 +
  10.687 +    OSL_ENSURE( pNewPgDescFmt || pNewPgDesc, "Neither page desc format nor page desc provided." );
  10.688 +
  10.689 +    if ( pNewPgDescFmt )
  10.690 +        m_pSections->AppendSep( *pNewPgDescFmt, rNd, pFmt, nLnNm );
  10.691 +    else if ( pNewPgDesc )
  10.692 +        m_pSections->AppendSep( pNewPgDesc, rNd, pFmt, nLnNm );
  10.693 +
  10.694 +    AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
  10.695 +}
  10.696 +
  10.697 +bool RtfExport::DisallowInheritingOutlineNumbering( const SwFmt& rFmt )
  10.698 +{
  10.699 +    bool bRet( false );
  10.700 +
  10.701 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.702 +
  10.703 +    if (SFX_ITEM_SET != rFmt.GetItemState(RES_PARATR_NUMRULE, false))
  10.704 +    {
  10.705 +        if (const SwFmt *pParent = rFmt.DerivedFrom())
  10.706 +        {
  10.707 +            if (((const SwTxtFmtColl*)pParent)->IsAssignedToListLevelOfOutlineStyle())
  10.708 +            {
  10.709 +                // Level 9 disables the outline
  10.710 +                Strm() << OOO_STRING_SVTOOLS_RTF_LEVEL << 9;
  10.711 +
  10.712 +                bRet = true;
  10.713 +            }
  10.714 +        }
  10.715 +    }
  10.716 +
  10.717 +    return bRet;
  10.718 +}
  10.719 +
  10.720 +void RtfExport::OutputGrfNode( const SwGrfNode& )
  10.721 +{
  10.722 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.723 +
  10.724 +    /* noop, see RtfAttributeOutput::FlyFrameGraphic */
  10.725 +}
  10.726 +
  10.727 +void RtfExport::OutputOLENode( const SwOLENode& )
  10.728 +{
  10.729 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.730 +
  10.731 +    /* noop, see RtfAttributeOutput::FlyFrameOLE */
  10.732 +}
  10.733 +
  10.734 +void RtfExport::AppendSection( const SwPageDesc* pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum )
  10.735 +{
  10.736 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  10.737 +
  10.738 +    m_pSections->AppendSep( pPageDesc, pFmt, nLnNum );
  10.739 +    AttrOutput().SectionBreak( msword::PageBreak, m_pSections->CurrentSectionInfo() );
  10.740 +}
  10.741 +
  10.742 +RtfExport::RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam, Writer* pWriter )
  10.743 +    : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
  10.744 +      m_pFilter( pFilter ),
  10.745 +      m_pWriter( pWriter ),
  10.746 +      m_pAttrOutput( NULL ),
  10.747 +      m_pSections( NULL ),
  10.748 +      m_pSdrExport( NULL ),
  10.749 +      eDefaultEncoding(
  10.750 +              rtl_getTextEncodingFromWindowsCharset(
  10.751 +                  sw::ms::rtl_TextEncodingToWinCharset(DEF_ENCODING))),
  10.752 +      eCurrentEncoding(eDefaultEncoding),
  10.753 +      bRTFFlySyntax(false)
  10.754 +{
  10.755 +    // the attribute output for the document
  10.756 +    m_pAttrOutput = new RtfAttributeOutput( *this );
  10.757 +    // that just causes problems for RTF
  10.758 +    bSubstituteBullets = false;
  10.759 +    // needed to have a complete font table
  10.760 +    maFontHelper.bLoadAllFonts = true;
  10.761 +    // the related SdrExport
  10.762 +    m_pSdrExport = new RtfSdrExport( *this );
  10.763 +
  10.764 +    if (!m_pWriter)
  10.765 +        m_pWriter = &m_pFilter->m_aWriter;
  10.766 +}
  10.767 +
  10.768 +RtfExport::~RtfExport()
  10.769 +{
  10.770 +    delete m_pAttrOutput, m_pAttrOutput = NULL;
  10.771 +    delete m_pSdrExport, m_pSdrExport = NULL;
  10.772 +}
  10.773 +
  10.774 +SvStream& RtfExport::Strm()
  10.775 +{
  10.776 +    return m_pWriter->Strm();
  10.777 +}
  10.778 +
  10.779 +SvStream& RtfExport::OutULong( ULONG nVal )
  10.780 +{
  10.781 +    return m_pWriter->OutULong( Strm(), nVal );
  10.782 +}
  10.783 +
  10.784 +SvStream& RtfExport::OutLong( long nVal )
  10.785 +{
  10.786 +    return m_pWriter->OutLong( Strm(), nVal );
  10.787 +}
  10.788 +
  10.789 +void RtfExport::OutUnicode(const sal_Char *pToken, const String &rContent)
  10.790 +{
  10.791 +    if (rContent.Len())
  10.792 +    {
  10.793 +        Strm() << '{' << pToken << ' ';
  10.794 +        Strm() << OUStringToOString( OUString( rContent ), eCurrentEncoding ).getStr();
  10.795 +        Strm() << '}';
  10.796 +    }
  10.797 +}
  10.798 +
  10.799 +OString RtfExport::OutHex(ULONG nHex, BYTE nLen)
  10.800 +{
  10.801 +    sal_Char aNToABuf[] = "0000000000000000";
  10.802 +
  10.803 +    OSL_ENSURE( nLen < sizeof(aNToABuf), "nLen is too big" );
  10.804 +    if( nLen >= sizeof(aNToABuf) )
  10.805 +        nLen = (sizeof(aNToABuf)-1);
  10.806 +
  10.807 +    // Set pointer to the buffer end
  10.808 +    sal_Char* pStr = aNToABuf + (sizeof(aNToABuf)-1);
  10.809 +    for( BYTE n = 0; n < nLen; ++n )
  10.810 +    {
  10.811 +        *(--pStr) = (sal_Char)(nHex & 0xf ) + 48;
  10.812 +        if( *pStr > '9' )
  10.813 +            *pStr += 39;
  10.814 +        nHex >>= 4;
  10.815 +    }
  10.816 +    return OString(pStr);
  10.817 +}
  10.818 +
  10.819 +OString RtfExport::OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEnc)
  10.820 +{
  10.821 +    OStringBuffer aBuf;
  10.822 +    const sal_Char* pStr = 0;
  10.823 +    // 0x0b instead of \n, etc because of the replacements in SwAttrIter::GetSnippet()
  10.824 +    switch (c)
  10.825 +    {
  10.826 +        case 0x0b:
  10.827 +            // hard line break
  10.828 +            pStr = OOO_STRING_SVTOOLS_RTF_LINE;
  10.829 +            break;
  10.830 +        case '\t':
  10.831 +            pStr = OOO_STRING_SVTOOLS_RTF_TAB;
  10.832 +            break;
  10.833 +        case '\\':
  10.834 +        case '}':
  10.835 +        case '{':
  10.836 +            aBuf.append('\\');
  10.837 +            aBuf.append((sal_Char)c);
  10.838 +            break;
  10.839 +        case 0xa0:
  10.840 +            // non-breaking space
  10.841 +            pStr = "\\~";
  10.842 +            break;
  10.843 +        case 0x1e:
  10.844 +            // non-breaking hyphen
  10.845 +            pStr = "\\_";
  10.846 +            break;
  10.847 +        case 0x1f:
  10.848 +            // optional hyphen
  10.849 +            pStr = "\\-";
  10.850 +            break;
  10.851 +        default:
  10.852 +            if (c >= ' ' && c <= '~')
  10.853 +                aBuf.append((sal_Char)c);
  10.854 +            else {
  10.855 +                //If we can't convert to the dest encoding, or if
  10.856 +                //its an uncommon multibyte sequence which most
  10.857 +                //readers won't be able to handle correctly, then
  10.858 +                //If we can't convert to the dest encoding, then
  10.859 +                //export as unicode
  10.860 +                OUString sBuf(&c, 1);
  10.861 +                OString sConverted;
  10.862 +                sal_uInt32 nFlags =
  10.863 +                    RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
  10.864 +                    RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR;
  10.865 +                bool bWriteAsUnicode = !(sBuf.convertToString(&sConverted,
  10.866 +                            eDestEnc, nFlags)) 
  10.867 +                    || (RTL_TEXTENCODING_UTF8==eDestEnc); // #i43933# do not export UTF-8 chars in RTF;
  10.868 +                if (bWriteAsUnicode)
  10.869 +                    sBuf.convertToString(&sConverted,
  10.870 +                            eDestEnc, OUSTRING_TO_OSTRING_CVTFLAGS);
  10.871 +                const sal_Int32 nLen = sConverted.getLength();
  10.872 +
  10.873 +                if (bWriteAsUnicode && pUCMode)
  10.874 +                {
  10.875 +                    // then write as unicode - character
  10.876 +                    if (*pUCMode != nLen)
  10.877 +                    {
  10.878 +                        aBuf.append("\\uc");
  10.879 +                        aBuf.append((sal_Int32)nLen);
  10.880 +                        // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored.
  10.881 +                        aBuf.append(' ');
  10.882 +                        *pUCMode = nLen;
  10.883 +                    }
  10.884 +                    aBuf.append("\\u");
  10.885 +                    aBuf.append((sal_Int32)c);
  10.886 +                }
  10.887 +
  10.888 +                for (sal_Int32 nI = 0; nI < nLen; ++nI)
  10.889 +                {
  10.890 +                    aBuf.append("\\'");
  10.891 +                    aBuf.append(OutHex(sConverted.getStr()[nI], 2));
  10.892 +                }
  10.893 +            }
  10.894 +    }
  10.895 +    if (pStr) {
  10.896 +        aBuf.append(pStr);
  10.897 +        aBuf.append(' ');
  10.898 +    }
  10.899 +    return aBuf.makeStringAndClear();
  10.900 +}
  10.901 +
  10.902 +OString RtfExport::OutString(const String &rStr, rtl_TextEncoding eDestEnc)
  10.903 +{
  10.904 +    OSL_TRACE("%s, rStr = '%s'", __PRETTY_FUNCTION__,
  10.905 +            OUStringToOString( OUString( rStr ), eCurrentEncoding ).getStr());
  10.906 +    OStringBuffer aBuf;
  10.907 +    int nUCMode = 1;
  10.908 +    for (xub_StrLen n = 0; n < rStr.Len(); ++n)
  10.909 +        aBuf.append(OutChar(rStr.GetChar(n), &nUCMode, eDestEnc));
  10.910 +    if (nUCMode != 1) {
  10.911 +        aBuf.append(OOO_STRING_SVTOOLS_RTF_UC);
  10.912 +        aBuf.append((sal_Int32)1);
  10.913 +        aBuf.append(" "); // #i47831# add an additional whitespace, so that "document whitespaces" are not ignored.;
  10.914 +    }
  10.915 +    return aBuf.makeStringAndClear();
  10.916 +}
  10.917 +
  10.918 +void RtfExport::OutDateTime(const sal_Char* pStr, const util::DateTime& rDT )
  10.919 +{
  10.920 +    Strm() << '{' << pStr << OOO_STRING_SVTOOLS_RTF_YR;
  10.921 +    OutULong( rDT.Year ) << OOO_STRING_SVTOOLS_RTF_MO;
  10.922 +    OutULong( rDT.Month ) << OOO_STRING_SVTOOLS_RTF_DY;
  10.923 +    OutULong( rDT.Day ) << OOO_STRING_SVTOOLS_RTF_HR;
  10.924 +    OutULong( rDT.Hours ) << OOO_STRING_SVTOOLS_RTF_MIN;
  10.925 +    OutULong( rDT.Minutes ) << '}';
  10.926 +}
  10.927 +
  10.928 +USHORT RtfExport::GetColor( const Color& rColor ) const
  10.929 +{
  10.930 +    for (RtfColorTbl::const_iterator it=m_aColTbl.begin() ; it != m_aColTbl.end(); it++ )
  10.931 +        if ((*it).second == rColor) {
  10.932 +            OSL_TRACE("%s returning %d (%d,%d,%d)", __PRETTY_FUNCTION__, (*it).first, rColor.GetRed(), rColor.GetGreen(), rColor.GetBlue());
  10.933 +            return (*it).first;
  10.934 +        }
  10.935 +    OSL_ENSURE( FALSE, "No such Color in m_aColTbl!" );
  10.936 +    return 0;
  10.937 +}
  10.938 +
  10.939 +void RtfExport::InsColor( const Color& rCol )
  10.940 +{
  10.941 +    USHORT n;
  10.942 +    for (RtfColorTbl::iterator it=m_aColTbl.begin() ; it != m_aColTbl.end(); it++ )
  10.943 +        if ((*it).second == rCol)
  10.944 +            return; // Already in the table
  10.945 +    if (rCol.GetColor() == COL_AUTO)
  10.946 +        n = 0;
  10.947 +    else
  10.948 +    {
  10.949 +        n = m_aColTbl.size();
  10.950 +        // Fix for the case when first a !COL_AUTO gets inserted as #0, then
  10.951 +        // gets overwritten by COL_AUTO
  10.952 +        if (!n)
  10.953 +            n++;
  10.954 +    }
  10.955 +    m_aColTbl.insert(std::pair<USHORT,Color>( n, rCol ));
  10.956 +}
  10.957 +
  10.958 +void RtfExport::InsColorLine( const SvxBoxItem& rBox )
  10.959 +{
  10.960 +    const SvxBorderLine* pLine = 0;
  10.961 +
  10.962 +    if( rBox.GetTop() )
  10.963 +        InsColor( (pLine = rBox.GetTop())->GetColor() );
  10.964 +    if( rBox.GetBottom() && pLine != rBox.GetBottom() )
  10.965 +        InsColor( (pLine = rBox.GetBottom())->GetColor() );
  10.966 +    if( rBox.GetLeft() && pLine != rBox.GetLeft()  )
  10.967 +        InsColor( (pLine = rBox.GetLeft())->GetColor() );
  10.968 +    if( rBox.GetRight() && pLine != rBox.GetRight()  )
  10.969 +        InsColor( rBox.GetRight()->GetColor() );
  10.970 +}
  10.971 +void RtfExport::OutColorTable()
  10.972 +{
  10.973 +    // Build the table from rPool since the colors provided to
  10.974 +    // RtfAttributeOutput callbacks are too late.
  10.975 +    USHORT n, nMaxItem;
  10.976 +    const SfxItemPool& rPool = pDoc->GetAttrPool();
  10.977 +
  10.978 +    // char color
  10.979 +    {
  10.980 +        const SvxColorItem* pCol = (const SvxColorItem*)GetDfltAttr(
  10.981 +                                                RES_CHRATR_COLOR );
  10.982 +        InsColor( pCol->GetValue() );
  10.983 +        if( 0 != ( pCol = (const SvxColorItem*)rPool.GetPoolDefaultItem(
  10.984 +                RES_CHRATR_COLOR ) ))
  10.985 +            InsColor( pCol->GetValue() );
  10.986 +        nMaxItem = rPool.GetItemCount(RES_CHRATR_COLOR);
  10.987 +        for( n = 0; n < nMaxItem; ++n )
  10.988 +        {
  10.989 +            if( 0 != (pCol = (const SvxColorItem*)rPool.GetItem(
  10.990 +                RES_CHRATR_COLOR, n ) ) )
  10.991 +                InsColor( pCol->GetValue() );
  10.992 +        }
  10.993 +
  10.994 +        const SvxUnderlineItem* pUnder = (const SvxUnderlineItem*)GetDfltAttr( RES_CHRATR_UNDERLINE );
  10.995 +        InsColor( pUnder->GetColor() );
  10.996 +        nMaxItem = rPool.GetItemCount(RES_CHRATR_UNDERLINE);
  10.997 +        for( n = 0; n < nMaxItem;n++)
  10.998 +        {
  10.999 +            if( 0 != (pUnder = (const SvxUnderlineItem*)rPool.GetItem( RES_CHRATR_UNDERLINE, n ) ) )
 10.1000 +                InsColor( pUnder->GetColor() );
 10.1001 +
 10.1002 +        }
 10.1003 +
 10.1004 +        const SvxOverlineItem* pOver = (const SvxOverlineItem*)GetDfltAttr( RES_CHRATR_OVERLINE );
 10.1005 +        InsColor( pOver->GetColor() );
 10.1006 +        nMaxItem = rPool.GetItemCount(RES_CHRATR_OVERLINE);
 10.1007 +        for( n = 0; n < nMaxItem;n++)
 10.1008 +        {
 10.1009 +            if( 0 != (pOver = (const SvxOverlineItem*)rPool.GetItem( RES_CHRATR_OVERLINE, n ) ) )
 10.1010 +                InsColor( pOver->GetColor() );
 10.1011 +
 10.1012 +        }
 10.1013 +
 10.1014 +    }
 10.1015 +
 10.1016 +    // background color
 10.1017 +    static const USHORT aBrushIds[] = {
 10.1018 +                                RES_BACKGROUND, RES_CHRATR_BACKGROUND, 0 };
 10.1019 +
 10.1020 +    for( const USHORT* pIds = aBrushIds; *pIds; ++pIds )
 10.1021 +    {
 10.1022 +        const SvxBrushItem* pBkgrd = (const SvxBrushItem*)GetDfltAttr( *pIds );
 10.1023 +        InsColor( pBkgrd->GetColor() );
 10.1024 +        if( 0 != ( pBkgrd = (const SvxBrushItem*)rPool.GetPoolDefaultItem(
 10.1025 +                        *pIds ) ))
 10.1026 +        {
 10.1027 +            InsColor( pBkgrd->GetColor() );
 10.1028 +        }
 10.1029 +        nMaxItem = rPool.GetItemCount( *pIds );
 10.1030 +        for( n = 0; n < nMaxItem; ++n )
 10.1031 +            if( 0 != (pBkgrd = (const SvxBrushItem*)rPool.GetItem(
 10.1032 +                    *pIds , n ) ))
 10.1033 +            {
 10.1034 +                InsColor( pBkgrd->GetColor() );
 10.1035 +            }
 10.1036 +    }
 10.1037 +
 10.1038 +    // shadow color
 10.1039 +    {
 10.1040 +        const SvxShadowItem* pShadow = (const SvxShadowItem*)GetDfltAttr(
 10.1041 +                                                            RES_SHADOW );
 10.1042 +        InsColor( pShadow->GetColor() );
 10.1043 +        if( 0 != ( pShadow = (const SvxShadowItem*)rPool.GetPoolDefaultItem(
 10.1044 +                        RES_SHADOW ) ))
 10.1045 +        {
 10.1046 +            InsColor( pShadow->GetColor() );
 10.1047 +        }
 10.1048 +        nMaxItem = rPool.GetItemCount(RES_SHADOW);
 10.1049 +        for( n = 0; n < nMaxItem; ++n )
 10.1050 +            if( 0 != (pShadow = (const SvxShadowItem*)rPool.GetItem(
 10.1051 +                RES_SHADOW, n ) ) )
 10.1052 +            {
 10.1053 +                InsColor( pShadow->GetColor() );
 10.1054 +            }
 10.1055 +    }
 10.1056 +
 10.1057 +    // frame border color
 10.1058 +    {
 10.1059 +        const SvxBoxItem* pBox;
 10.1060 +        if( 0 != ( pBox = (const SvxBoxItem*)rPool.GetPoolDefaultItem(
 10.1061 +                        RES_BOX ) ))
 10.1062 +            InsColorLine( *pBox );
 10.1063 +        nMaxItem = rPool.GetItemCount(RES_BOX);
 10.1064 +        for( n = 0; n < nMaxItem; ++n )
 10.1065 +            if( 0 != (pBox = (const SvxBoxItem*)rPool.GetItem( RES_BOX, n ) ))
 10.1066 +                InsColorLine( *pBox );
 10.1067 +    }
 10.1068 +
 10.1069 +    for( n = 0; n < m_aColTbl.size(); n++ )
 10.1070 +    {
 10.1071 +        const Color& rCol = m_aColTbl[ n ];
 10.1072 +        if( n || COL_AUTO != rCol.GetColor() )
 10.1073 +        {
 10.1074 +            Strm() << OOO_STRING_SVTOOLS_RTF_RED;
 10.1075 +            OutULong( rCol.GetRed() ) << OOO_STRING_SVTOOLS_RTF_GREEN;
 10.1076 +            OutULong( rCol.GetGreen() ) << OOO_STRING_SVTOOLS_RTF_BLUE;
 10.1077 +            OutULong( rCol.GetBlue() );
 10.1078 +        }
 10.1079 +        Strm() << ';';
 10.1080 +    }
 10.1081 +}
 10.1082 +
 10.1083 +void RtfExport::InsStyle( USHORT nId, const OString& rStyle )
 10.1084 +{
 10.1085 +    m_aStyTbl.insert(std::pair<USHORT,OString>(nId, rStyle) );
 10.1086 +}
 10.1087 +
 10.1088 +OString* RtfExport::GetStyle( USHORT nId )
 10.1089 +{
 10.1090 +    std::map<USHORT,OString>::iterator i = m_aStyTbl.find(nId);
 10.1091 +    if (i != m_aStyTbl.end())
 10.1092 +        return &i->second;
 10.1093 +    return NULL;
 10.1094 +}
 10.1095 +
 10.1096 +USHORT RtfExport::GetRedline( const String& rAuthor )
 10.1097 +{
 10.1098 +    std::map<String,USHORT>::iterator i = m_aRedlineTbl.find(rAuthor);
 10.1099 +    if (i != m_aRedlineTbl.end())
 10.1100 +        return i->second;
 10.1101 +    else
 10.1102 +    {
 10.1103 +        int nId = m_aRedlineTbl.size();
 10.1104 +        m_aRedlineTbl.insert(std::pair<String,USHORT>(rAuthor,nId));
 10.1105 +        return nId;
 10.1106 +    }
 10.1107 +}
 10.1108 +
 10.1109 +void RtfExport::OutPageDescription( const SwPageDesc& rPgDsc, BOOL bWriteReset, BOOL bCheckForFirstPage )
 10.1110 +{
 10.1111 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
 10.1112 +    const SwPageDesc *pSave = pAktPageDesc;
 10.1113 +
 10.1114 +    pAktPageDesc = &rPgDsc;
 10.1115 +    if( bCheckForFirstPage && pAktPageDesc->GetFollow() &&
 10.1116 +            pAktPageDesc->GetFollow() != pAktPageDesc )
 10.1117 +        pAktPageDesc = pAktPageDesc->GetFollow();
 10.1118 +
 10.1119 +    if( bWriteReset )
 10.1120 +    {
 10.1121 +        if( pCurPam->GetPoint()->nNode == pOrigPam->Start()->nNode )
 10.1122 +            Strm() << OOO_STRING_SVTOOLS_RTF_SECTD << OOO_STRING_SVTOOLS_RTF_SBKNONE;
 10.1123 +        else
 10.1124 +            Strm() << OOO_STRING_SVTOOLS_RTF_SECT << OOO_STRING_SVTOOLS_RTF_SECTD;
 10.1125 +    }
 10.1126 +
 10.1127 +    if( pAktPageDesc->GetLandscape() )
 10.1128 +        Strm() << OOO_STRING_SVTOOLS_RTF_LNDSCPSXN;
 10.1129 +
 10.1130 +    const SwFmt *pFmt = &pAktPageDesc->GetMaster(); //GetLeft();
 10.1131 +    bOutPageDescs = true;
 10.1132 +    OutputFormat(*pFmt, true, false);
 10.1133 +    bOutPageDescs = false;
 10.1134 +
 10.1135 +    // normal header / footer (without a style)
 10.1136 +    const SfxPoolItem* pItem;
 10.1137 +    if( pAktPageDesc->GetLeft().GetAttrSet().GetItemState( RES_HEADER, FALSE,
 10.1138 +                &pItem ) == SFX_ITEM_SET)
 10.1139 +        WriteHeaderFooter(*pItem, true);
 10.1140 +    if( pAktPageDesc->GetLeft().GetAttrSet().GetItemState( RES_FOOTER, FALSE,
 10.1141 +                &pItem ) == SFX_ITEM_SET)
 10.1142 +        WriteHeaderFooter(*pItem, false);
 10.1143 +
 10.1144 +    // title page
 10.1145 +    if( pAktPageDesc != &rPgDsc )
 10.1146 +    {
 10.1147 +        pAktPageDesc = &rPgDsc;
 10.1148 +        if( pAktPageDesc->GetMaster().GetAttrSet().GetItemState( RES_HEADER,
 10.1149 +                    FALSE, &pItem ) == SFX_ITEM_SET )
 10.1150 +            WriteHeaderFooter(*pItem, true);
 10.1151 +        if( pAktPageDesc->GetMaster().GetAttrSet().GetItemState( RES_FOOTER,
 10.1152 +                    FALSE, &pItem ) == SFX_ITEM_SET )
 10.1153 +            WriteHeaderFooter(*pItem, false);
 10.1154 +    }
 10.1155 +
 10.1156 +    // numbering type
 10.1157 +    AttrOutput().SectionPageNumbering(pAktPageDesc->GetNumType().GetNumberingType(), 0);
 10.1158 +
 10.1159 +    pAktPageDesc = pSave;
 10.1160 +    //bOutPageDesc = bOldOut;
 10.1161 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
 10.1162 +}
 10.1163 +
 10.1164 +void RtfExport::WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader)
 10.1165 +{
 10.1166 +    if (bHeader)
 10.1167 +    {
 10.1168 +        const SwFmtHeader& rHeader = (const SwFmtHeader&)rItem;
 10.1169 +        if (!rHeader.IsActive())
 10.1170 +            return;
 10.1171 +    }
 10.1172 +    else
 10.1173 +    {
 10.1174 +        const SwFmtFooter& rFooter = (const SwFmtFooter&)rItem;
 10.1175 +        if (!rFooter.IsActive())
 10.1176 +            return;
 10.1177 +    }
 10.1178 +
 10.1179 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
 10.1180 +
 10.1181 +    Strm() << (bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERY : OOO_STRING_SVTOOLS_RTF_FOOTERY);
 10.1182 +    OutLong( pAktPageDesc->GetMaster().
 10.1183 +            GetULSpace().GetUpper() );
 10.1184 +    const sal_Char* pStr = (bHeader ? OOO_STRING_SVTOOLS_RTF_HEADER : OOO_STRING_SVTOOLS_RTF_FOOTER);
 10.1185 +    /* is this a title page? */
 10.1186 +    if( pAktPageDesc->GetFollow() && pAktPageDesc->GetFollow() != pAktPageDesc )
 10.1187 +    {
 10.1188 +        Strm() << OOO_STRING_SVTOOLS_RTF_TITLEPG;
 10.1189 +        pStr = (bHeader ? OOO_STRING_SVTOOLS_RTF_HEADERF : OOO_STRING_SVTOOLS_RTF_FOOTERF);
 10.1190 +    }
 10.1191 +    Strm() << '{' << pStr;
 10.1192 +    WriteHeaderFooterText(pAktPageDesc->GetMaster(), bHeader);
 10.1193 +    Strm() << '}';
 10.1194 +
 10.1195 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
 10.1196 +}
 10.1197 +
 10.1198 +void RtfExport::WriteHeaderFooter(const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr)
 10.1199 +{
 10.1200 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
 10.1201 +
 10.1202 +    m_pAttrOutput->WriteHeaderFooter_Impl( rFmt, bHeader, pStr );
 10.1203 +
 10.1204 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
 10.1205 +}
 10.1206 +
 10.1207 +class SwRTFUNOWriter : public Writer
 10.1208 +{
 10.1209 +       public:
 10.1210 +               SwRTFUNOWriter( const String& rFilterName, const String& rBaseURL );
 10.1211 +               virtual ~SwRTFUNOWriter();
 10.1212 +               virtual ULONG WriteStream();
 10.1213 +};
 10.1214 +
 10.1215 +SwRTFUNOWriter::SwRTFUNOWriter( const String& /*rFltName*/, const String & rBaseURL )
 10.1216 +{
 10.1217 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
 10.1218 +    SetBaseURL( rBaseURL );
 10.1219 +}
 10.1220 +
 10.1221 +SwRTFUNOWriter::~SwRTFUNOWriter()
 10.1222 +{}
 10.1223 +
 10.1224 +ULONG SwRTFUNOWriter::WriteStream()
 10.1225 +{
 10.1226 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
 10.1227 +    RtfExport aExport( NULL, pDoc, new SwPaM( *pCurPam->End(), *pCurPam->Start() ), pCurPam, this );
 10.1228 +    aExport.ExportDocument( true );
 10.1229 +    return 0;
 10.1230 +}
 10.1231 +
 10.1232 +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportRTF( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
 10.1233 +{
 10.1234 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
 10.1235 +    xRet = new SwRTFUNOWriter( rFltName, rBaseURL );
 10.1236 +}
 10.1237 +
 10.1238 +/* vi:set shiftwidth=4 expandtab: */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/sw/source/filter/ww8/rtfexport.hxx	Thu Jul 29 22:01:25 2010 +0200
    11.3 @@ -0,0 +1,210 @@
    11.4 +/*************************************************************************
    11.5 + *
    11.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    11.7 + *
    11.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    11.9 + * Copyright 2010 Miklos Vajna.
   11.10 + *
   11.11 + * OpenOffice.org - a multi-platform office productivity suite
   11.12 + *
   11.13 + * This file is part of OpenOffice.org.
   11.14 + *
   11.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   11.16 + * it under the terms of the GNU Lesser General Public License version 3
   11.17 + * only, as published by the Free Software Foundation.
   11.18 + *
   11.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   11.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11.22 + * GNU Lesser General Public License version 3 for more details
   11.23 + * (a copy is included in the LICENSE file that accompanied this code).
   11.24 + *
   11.25 + * You should have received a copy of the GNU Lesser General Public License
   11.26 + * version 3 along with OpenOffice.org.  If not, see
   11.27 + * <http://www.openoffice.org/license.html>
   11.28 + * for a copy of the LGPLv3 License.
   11.29 + *
   11.30 + ************************************************************************/
   11.31 +
   11.32 +#ifndef _RTFEXPORT_HXX_
   11.33 +#define _RTFEXPORT_HXX_
   11.34 +
   11.35 +#include "rtfattributeoutput.hxx"
   11.36 +#include "wrtww8.hxx"
   11.37 +
   11.38 +#include <rtl/ustring.hxx>
   11.39 +
   11.40 +#include <cstdio>
   11.41 +#include <map>
   11.42 +
   11.43 +class RtfExportFilter;
   11.44 +class RtfSdrExport;
   11.45 +typedef std::map<USHORT,Color> RtfColorTbl;
   11.46 +typedef std::map<USHORT,rtl::OString> RtfStyleTbl;
   11.47 +typedef std::map<String,USHORT> RtfRedlineTbl;
   11.48 +class SwNode;
   11.49 +class SwEndNode;
   11.50 +class SwTableNode;
   11.51 +class SwTxtNode;
   11.52 +class SwGrfNode;
   11.53 +class SwOLENode;
   11.54 +class SwSectionNode;
   11.55 +class SwNumRuleTbl;
   11.56 +
   11.57 +namespace com { namespace sun { namespace star {
   11.58 +    namespace frame { class XModel; }
   11.59 +} } }    
   11.60 +
   11.61 +/// The class that does all the actual RTF export-related work.
   11.62 +class RtfExport : public MSWordExportBase
   11.63 +{
   11.64 +    /// Pointer to the filter that owns us.
   11.65 +    RtfExportFilter *m_pFilter;
   11.66 +    Writer* m_pWriter;
   11.67 +
   11.68 +    /// Attribute output for document.
   11.69 +    RtfAttributeOutput *m_pAttrOutput;
   11.70 +
   11.71 +    /// Sections/headers/footers
   11.72 +    MSWordSections *m_pSections;
   11.73 +
   11.74 +    RtfSdrExport *m_pSdrExport;
   11.75 +
   11.76 +public:
   11.77 +    /// Access to the attribute output class.
   11.78 +    virtual AttributeOutputBase& AttrOutput() const;
   11.79 +
   11.80 +    /// Access to the sections/headers/footres.
   11.81 +    virtual MSWordSections& Sections() const;
   11.82 +
   11.83 +    /// Access to the Rtf Sdr exporter.
   11.84 +    virtual RtfSdrExport& SdrExporter() const;
   11.85 +
   11.86 +    /// Hack, unfortunately necessary at some places for now.
   11.87 +    virtual bool HackIsWW8OrHigher() const { return true; }
   11.88 +
   11.89 +    /// Guess the script (asian/western).
   11.90 +    virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich );
   11.91 +
   11.92 +    virtual void AppendBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen );
   11.93 +
   11.94 +    virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false );
   11.95 +
   11.96 +    virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t /*pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t()*/ ) { /* no-op for rtf, most probably should not even be in MSWordExportBase */ }
   11.97 +    virtual void WriteChar( sal_Unicode );
   11.98 +
   11.99 +    /// Write the numbering table.
  11.100 +    virtual void WriteNumbering();
  11.101 +
  11.102 +    /// Write the revision table.
  11.103 +    virtual void WriteRevTab();
  11.104 +
  11.105 +    /// Output the actual headers and footers.
  11.106 +    virtual void WriteHeadersFooters( BYTE nHeadFootFlags,
  11.107 +            const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, BYTE nBreakCode );
  11.108 +
  11.109 +    /// Write the field
  11.110 +    virtual void OutputField( const SwField* pFld, ww::eField eFldType,
  11.111 +            const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL );
  11.112 +
  11.113 +    /// Write the data of the form field
  11.114 +    virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
  11.115 +    virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark );
  11.116 +    
  11.117 +    virtual void DoComboBox(const rtl::OUString &rName,
  11.118 +                    const rtl::OUString &rHelp,
  11.119 +                    const rtl::OUString &ToolTip,
  11.120 +                    const rtl::OUString &rSelected,
  11.121 +                    com::sun::star::uno::Sequence<rtl::OUString> &rListItems);
  11.122 +
  11.123 +    virtual void DoFormText(const SwInputField * pFld);
  11.124 +    
  11.125 +    virtual ULONG ReplaceCr( BYTE nChar );
  11.126 +
  11.127 +protected:
  11.128 +    /// Format-dependant part of the actual export.
  11.129 +    virtual void ExportDocument_Impl();
  11.130 +
  11.131 +    virtual void SectionBreaksAndFrames( const SwTxtNode& /*rNode*/ ) {}
  11.132 +
  11.133 +    /// Get ready for a new section.
  11.134 +    virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
  11.135 +                                     const SwNode& rNd,
  11.136 +                                     const SwFmtPageDesc* pNewPgDescFmt = 0,
  11.137 +                                     const SwPageDesc* pNewPgDesc = 0 );
  11.138 +
  11.139 +    /// Return value indicates if an inherited outline numbering is suppressed.
  11.140 +    virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt);
  11.141 +
  11.142 +    /// Output SwGrfNode
  11.143 +    virtual void OutputGrfNode( const SwGrfNode& );
  11.144 +
  11.145 +    /// Output SwOLENode
  11.146 +    virtual void OutputOLENode( const SwOLENode& );
  11.147 +
  11.148 +    virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum );
  11.149 +
  11.150 +public:
  11.151 +    /// Pass the pDocument, pCurrentPam and pOriginalPam to the base class.
  11.152 +    RtfExport( RtfExportFilter *pFilter, SwDoc *pDocument,
  11.153 +            SwPaM *pCurrentPam, SwPaM *pOriginalPam, Writer* pWriter );
  11.154 +
  11.155 +    /// Destructor.
  11.156 +    virtual ~RtfExport();
  11.157 +
  11.158 +#if defined(UNX)
  11.159 +    static const sal_Char sNewLine; // \012 or \015
  11.160 +#else
  11.161 +    static const sal_Char __FAR_DATA sNewLine[]; // \015\012
  11.162 +#endif
  11.163 +
  11.164 +    rtl_TextEncoding eDefaultEncoding;
  11.165 +    rtl_TextEncoding eCurrentEncoding;
  11.166 +    /// This is used by OutputFlyFrame_Impl() to control the written syntax
  11.167 +    bool bRTFFlySyntax;
  11.168 +
  11.169 +    BOOL m_bOutStyleTab : 1;
  11.170 +    SvStream& Strm();
  11.171 +    SvStream& OutULong( ULONG nVal );
  11.172 +    SvStream& OutLong( long nVal );
  11.173 +    void OutUnicode(const sal_Char *pToken, const String &rContent);
  11.174 +    void OutDateTime(const sal_Char* pStr, const util::DateTime& rDT );
  11.175 +    rtl::OString OutChar(sal_Unicode c, int *pUCMode, rtl_TextEncoding eDestEnc);
  11.176 +    rtl::OString OutString(const String &rStr, rtl_TextEncoding eDestEnc);
  11.177 +    rtl::OString OutHex(ULONG nHex, BYTE nLen);
  11.178 +    void OutPageDescription( const SwPageDesc& rPgDsc, BOOL bWriteReset, BOOL bCheckForFirstPage );
  11.179 +
  11.180 +    USHORT GetColor( const Color& rColor ) const;
  11.181 +    void InsColor( const Color& rCol );
  11.182 +    void InsColorLine( const SvxBoxItem& rBox );
  11.183 +    void OutColorTable();
  11.184 +    USHORT GetRedline( const String& rAuthor );
  11.185 +
  11.186 +    void InsStyle( USHORT nId, const rtl::OString& rStyle );
  11.187 +    rtl::OString* GetStyle( USHORT nId );
  11.188 +
  11.189 +private:
  11.190 +    /// No copying.
  11.191 +    RtfExport( const RtfExport& );
  11.192 +
  11.193 +    /// No copying.
  11.194 +    RtfExport& operator=( const RtfExport& );
  11.195 +
  11.196 +    void WriteFonts();
  11.197 +    void WriteStyles();
  11.198 +    void WriteMainText();
  11.199 +    void WriteInfo();
  11.200 +    /// Writes the writer-specific \pgdsctbl group.
  11.201 +    void WritePageDescTable();
  11.202 +    /// This is necessary to have the numbering table ready before the main text is being processed.
  11.203 +    void BuildNumbering();
  11.204 +    void WriteHeaderFooter(const SfxPoolItem& rItem, bool bHeader);
  11.205 +    void WriteHeaderFooter(const SwFrmFmt& rFmt, bool bHeader, const sal_Char* pStr);
  11.206 +
  11.207 +    RtfColorTbl m_aColTbl;
  11.208 +    RtfStyleTbl m_aStyTbl;
  11.209 +    RtfRedlineTbl m_aRedlineTbl;
  11.210 +};
  11.211 +
  11.212 +#endif // _RTFEXPORT_HXX_
  11.213 +/* vi:set shiftwidth=4 expandtab: */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/sw/source/filter/ww8/rtfexportfilter.cxx	Thu Jul 29 22:01:25 2010 +0200
    12.3 @@ -0,0 +1,136 @@
    12.4 +/*************************************************************************
    12.5 + *
    12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    12.7 + *
    12.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    12.9 + * Copyright 2010 Miklos Vajna.
   12.10 + *
   12.11 + * OpenOffice.org - a multi-platform office productivity suite
   12.12 + *
   12.13 + * This file is part of OpenOffice.org.
   12.14 + *
   12.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   12.16 + * it under the terms of the GNU Lesser General Public License version 3
   12.17 + * only, as published by the Free Software Foundation.
   12.18 + *
   12.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   12.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12.22 + * GNU Lesser General Public License version 3 for more details
   12.23 + * (a copy is included in the LICENSE file that accompanied this code).
   12.24 + *
   12.25 + * You should have received a copy of the GNU Lesser General Public License
   12.26 + * version 3 along with OpenOffice.org.  If not, see
   12.27 + * <http://www.openoffice.org/license.html>
   12.28 + * for a copy of the LGPLv3 License.
   12.29 + *
   12.30 + ************************************************************************/
   12.31 +
   12.32 +#include "rtfexportfilter.hxx"
   12.33 +#include "rtfexport.hxx"
   12.34 +
   12.35 +#include <docsh.hxx>
   12.36 +#include <doc.hxx>
   12.37 +#include <pam.hxx>
   12.38 +#include <unotxdoc.hxx>
   12.39 +
   12.40 +#include <cppuhelper/factory.hxx>
   12.41 +#include <comphelper/mediadescriptor.hxx>
   12.42 +#include <unotools/ucbstreamhelper.hxx>
   12.43 +
   12.44 +using namespace ::comphelper;
   12.45 +using namespace ::com::sun::star;
   12.46 +using ::rtl::OUString;
   12.47 +
   12.48 +RtfExportFilter::RtfExportFilter( const uno::Reference< lang::XMultiServiceFactory >& xMSF)  :
   12.49 +    m_xMSF( xMSF )
   12.50 +{
   12.51 +}
   12.52 +
   12.53 +RtfExportFilter::~RtfExportFilter()
   12.54 +{
   12.55 +}
   12.56 +
   12.57 +sal_Bool RtfExportFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
   12.58 +    throw (uno::RuntimeException)
   12.59 +{
   12.60 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   12.61 +
   12.62 +    MediaDescriptor aMediaDesc = aDescriptor;
   12.63 +    ::uno::Reference< io::XStream > xStream =
   12.64 +        aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_STREAMFOROUTPUT(), uno::Reference< io::XStream >() );
   12.65 +    m_pStream = utl::UcbStreamHelper::CreateStream( xStream, sal_True );
   12.66 +    m_aWriter.SetStrm(*m_pStream);
   12.67 +
   12.68 +    // get SwDoc*
   12.69 +    uno::Reference< uno::XInterface > xIfc( m_xSrcDoc, uno::UNO_QUERY );
   12.70 +    SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
   12.71 +    if ( !pTxtDoc ) {
   12.72 +        return sal_False;
   12.73 +    }
   12.74 +
   12.75 +    SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
   12.76 +    if ( !pDoc ) {
   12.77 +        return sal_False;
   12.78 +    }
   12.79 +
   12.80 +    // get SwPaM*
   12.81 +    // we get SwPaM for the entire document; copy&paste is handled internally, not via UNO
   12.82 +    SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
   12.83 +    aPam.SetMark();
   12.84 +    aPam.Move( fnMoveBackward, fnGoDoc );
   12.85 +
   12.86 +    SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
   12.87 +
   12.88 +    // export the document
   12.89 +    // (in a separate block so that it's destructed before the commit)
   12.90 +    {
   12.91 +        RtfExport aExport( this, pDoc, pCurPam, &aPam, NULL );
   12.92 +        aExport.ExportDocument( true );
   12.93 +    }
   12.94 +
   12.95 +    // delete the pCurPam
   12.96 +    if ( pCurPam )
   12.97 +    {
   12.98 +        while ( pCurPam->GetNext() != pCurPam )
   12.99 +            delete pCurPam->GetNext();
  12.100 +        delete pCurPam;
  12.101 +    }
  12.102 +    delete m_pStream;
  12.103 +
  12.104 +    return sal_True;
  12.105 +}
  12.106 +
  12.107 +
  12.108 +void RtfExportFilter::cancel(  ) throw (uno::RuntimeException)
  12.109 +{
  12.110 +}
  12.111 +
  12.112 +void RtfExportFilter::setSourceDocument( const uno::Reference< lang::XComponent >& xDoc )
  12.113 +    throw (lang::IllegalArgumentException, uno::RuntimeException)
  12.114 +{
  12.115 +    m_xSrcDoc = xDoc;
  12.116 +}
  12.117 +
  12.118 +//////////////////////////////////////////////////////////////////////////
  12.119 +// UNO helpers
  12.120 +//////////////////////////////////////////////////////////////////////////
  12.121 +
  12.122 +OUString RtfExport_getImplementationName()
  12.123 +{
  12.124 +    return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPL_NAME_RTFEXPORT ) );
  12.125 +}
  12.126 +
  12.127 +uno::Sequence< OUString > SAL_CALL RtfExport_getSupportedServiceNames() throw()
  12.128 +{
  12.129 +    const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ExportFilter" ) );
  12.130 +    const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
  12.131 +    return aSeq;
  12.132 +}
  12.133 +
  12.134 +uno::Reference< uno::XInterface > SAL_CALL RtfExport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
  12.135 +{
  12.136 +    return (cppu::OWeakObject*) new RtfExportFilter( rSMgr );
  12.137 +}
  12.138 +
  12.139 +/* vi:set shiftwidth=4 expandtab: */
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/sw/source/filter/ww8/rtfexportfilter.hxx	Thu Jul 29 22:01:25 2010 +0200
    13.3 @@ -0,0 +1,85 @@
    13.4 +/*************************************************************************
    13.5 + *
    13.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    13.7 + *
    13.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    13.9 + * Copyright 2010 Miklos Vajna.
   13.10 + *
   13.11 + * OpenOffice.org - a multi-platform office productivity suite
   13.12 + *
   13.13 + * This file is part of OpenOffice.org.
   13.14 + *
   13.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   13.16 + * it under the terms of the GNU Lesser General Public License version 3
   13.17 + * only, as published by the Free Software Foundation.
   13.18 + *
   13.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   13.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13.22 + * GNU Lesser General Public License version 3 for more details
   13.23 + * (a copy is included in the LICENSE file that accompanied this code).
   13.24 + *
   13.25 + * You should have received a copy of the GNU Lesser General Public License
   13.26 + * version 3 along with OpenOffice.org.  If not, see
   13.27 + * <http://www.openoffice.org/license.html>
   13.28 + * for a copy of the LGPLv3 License.
   13.29 + *
   13.30 + ************************************************************************/
   13.31 +
   13.32 +#ifndef _RTFEXPORTFILTER_HXX_
   13.33 +#define _RTFEXPORTFILTER_HXX_
   13.34 +
   13.35 +#include <com/sun/star/document/XFilter.hpp>
   13.36 +#include <com/sun/star/document/XExporter.hpp>
   13.37 +#include <com/sun/star/uno/XComponentContext.hpp>
   13.38 +#include <cppuhelper/implbase2.hxx>
   13.39 +#include <tools/stream.hxx>
   13.40 +#include <shellio.hxx>
   13.41 +
   13.42 +// This is just here so that we don't have to copy&paste its string format methods
   13.43 +class RtfWriter : public Writer
   13.44 +{
   13.45 +protected:
   13.46 +    ULONG WriteStream() { return 0; }
   13.47 +};
   13.48 +
   13.49 +/// The physical access to the RTF document (for writing).
   13.50 +class RtfExportFilter : public cppu::WeakImplHelper2
   13.51 +<
   13.52 +    com::sun::star::document::XFilter,
   13.53 +    com::sun::star::document::XExporter
   13.54 +>
   13.55 +{
   13.56 +protected:
   13.57 +    ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
   13.58 +    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xSrcDoc;
   13.59 +    SvStream* m_pStream;
   13.60 +public:
   13.61 +    RtfExportFilter( const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
   13.62 +    virtual ~RtfExportFilter();
   13.63 +
   13.64 +    // XFilter
   13.65 +    virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
   13.66 +        throw (::com::sun::star::uno::RuntimeException);
   13.67 +    virtual void SAL_CALL cancel(  )
   13.68 +        throw (::com::sun::star::uno::RuntimeException);
   13.69 +
   13.70 +    // XExporter
   13.71 +    virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
   13.72 +        throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
   13.73 +
   13.74 +    RtfWriter m_aWriter;
   13.75 +};
   13.76 +
   13.77 +::rtl::OUString RtfExport_getImplementationName();
   13.78 +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL RtfExport_getSupportedServiceNames()
   13.79 +    throw();
   13.80 +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL RtfExport_createInstance(
   13.81 +                                                                        const ::com::sun::star::uno::Reference<
   13.82 +                                                                        com::sun::star::lang::XMultiServiceFactory > &xMSF)
   13.83 +    throw( ::com::sun::star::uno::Exception );
   13.84 +
   13.85 +#define IMPL_NAME_RTFEXPORT "com.sun.star.comp.Writer.RtfExport"
   13.86 +
   13.87 +#endif // _RTFEXPORTFILTER_HXX_
   13.88 +/* vi:set shiftwidth=4 expandtab: */
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/sw/source/filter/ww8/rtfimportfilter.cxx	Thu Jul 29 22:01:25 2010 +0200
    14.3 @@ -0,0 +1,135 @@
    14.4 +/*************************************************************************
    14.5 + *
    14.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    14.7 + *
    14.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    14.9 + * Copyright 2010 Miklos Vajna.
   14.10 + *
   14.11 + * OpenOffice.org - a multi-platform office productivity suite
   14.12 + *
   14.13 + * This file is part of OpenOffice.org.
   14.14 + *
   14.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   14.16 + * it under the terms of the GNU Lesser General Public License version 3
   14.17 + * only, as published by the Free Software Foundation.
   14.18 + *
   14.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   14.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14.22 + * GNU Lesser General Public License version 3 for more details
   14.23 + * (a copy is included in the LICENSE file that accompanied this code).
   14.24 + *
   14.25 + * You should have received a copy of the GNU Lesser General Public License
   14.26 + * version 3 along with OpenOffice.org.  If not, see
   14.27 + * <http://www.openoffice.org/license.html>
   14.28 + * for a copy of the LGPLv3 License.
   14.29 + *
   14.30 + ************************************************************************/
   14.31 +
   14.32 +#include "rtfimportfilter.hxx"
   14.33 +#include "../rtf/swparrtf.hxx"
   14.34 +
   14.35 +#include <docsh.hxx>
   14.36 +#include <doc.hxx>
   14.37 +#include <pam.hxx>
   14.38 +#include <unotxdoc.hxx>
   14.39 +#include <swerror.h>
   14.40 +
   14.41 +#include <cppuhelper/factory.hxx>
   14.42 +#include <comphelper/mediadescriptor.hxx>
   14.43 +#include <unotools/ucbstreamhelper.hxx>
   14.44 +
   14.45 +#include <com/sun/star/frame/XDesktop.hpp>
   14.46 +#include <com/sun/star/frame/XComponentLoader.hpp>
   14.47 +
   14.48 +using namespace ::comphelper;
   14.49 +using namespace ::com::sun::star;
   14.50 +using ::rtl::OUString;
   14.51 +using rtl::OUStringToOString;
   14.52 +
   14.53 +RtfImportFilter::RtfImportFilter( const uno::Reference< lang::XMultiServiceFactory >& xMSF)  :
   14.54 +    m_xMSF( xMSF )
   14.55 +{
   14.56 +}
   14.57 +
   14.58 +RtfImportFilter::~RtfImportFilter()
   14.59 +{
   14.60 +}
   14.61 +
   14.62 +sal_Bool RtfImportFilter::filter( const uno::Sequence< beans::PropertyValue >& aDescriptor )
   14.63 +    throw (uno::RuntimeException)
   14.64 +{
   14.65 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   14.66 +
   14.67 +    MediaDescriptor aMediaDesc = aDescriptor;
   14.68 +    ::uno::Reference< io::XInputStream > xInputStream =
   14.69 +        aMediaDesc.getUnpackedValueOrDefault( MediaDescriptor::PROP_INPUTSTREAM(), uno::Reference< io::XInputStream >() );
   14.70 +    SvStream* pStream = utl::UcbStreamHelper::CreateStream( xInputStream, sal_True );
   14.71 +    if (!pStream)
   14.72 +        return sal_False;
   14.73 +
   14.74 +    // get SwDoc*
   14.75 +    uno::Reference< uno::XInterface > xIfc( m_xDstDoc, uno::UNO_QUERY );
   14.76 +    SwXTextDocument *pTxtDoc = dynamic_cast< SwXTextDocument * >( xIfc.get() );
   14.77 +    if (!pTxtDoc)
   14.78 +        return sal_False;
   14.79 +    SwDoc *pDoc = pTxtDoc->GetDocShell()->GetDoc();
   14.80 +    if (!pDoc)
   14.81 +        return sal_False;
   14.82 +
   14.83 +    // get SwPaM*
   14.84 +    // NEEDSWORK should we care about partial imports? For now we just import
   14.85 +    // the whole document
   14.86 +    SwPaM aPam( pDoc->GetNodes().GetEndOfContent() );
   14.87 +    aPam.SetMark();
   14.88 +    aPam.Move( fnMoveBackward, fnGoDoc );
   14.89 +    SwPaM *pCurPam = new SwPaM( *aPam.End(), *aPam.Start() );
   14.90 +
   14.91 +    String aURL;
   14.92 +    OUString sTemp;
   14.93 +    for ( sal_Int32 i = 0; i < aDescriptor.getLength(); i++ )
   14.94 +    {
   14.95 +        if( aDescriptor[i].Name == OUString(RTL_CONSTASCII_USTRINGPARAM("URL")) )
   14.96 +        {
   14.97 +            aDescriptor[i].Value >>= sTemp;
   14.98 +            aURL = sTemp;
   14.99 +        }
  14.100 +    }
  14.101 +
  14.102 +    RtfReader aReader;
  14.103 +    return aReader.Read(pStream, *pDoc, aURL, *pCurPam) == 0;
  14.104 +}
  14.105 +
  14.106 +
  14.107 +void RtfImportFilter::cancel(  ) throw (uno::RuntimeException)
  14.108 +{
  14.109 +}
  14.110 +
  14.111 +void RtfImportFilter::setTargetDocument( const uno::Reference< lang::XComponent >& xDoc )
  14.112 +    throw (lang::IllegalArgumentException, uno::RuntimeException)
  14.113 +{
  14.114 +    m_xDstDoc = xDoc;
  14.115 +}
  14.116 +
  14.117 +//////////////////////////////////////////////////////////////////////////
  14.118 +// UNO helpers
  14.119 +//////////////////////////////////////////////////////////////////////////
  14.120 +
  14.121 +OUString RtfImport_getImplementationName()
  14.122 +{
  14.123 +    return OUString( RTL_CONSTASCII_USTRINGPARAM( IMPL_NAME_RTFIMPORT ) );
  14.124 +}
  14.125 +
  14.126 +uno::Sequence< OUString > SAL_CALL RtfImport_getSupportedServiceNames() throw()
  14.127 +{
  14.128 +    const OUString aServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.document.ImportFilter" ) );
  14.129 +    const uno::Sequence< OUString > aSeq( &aServiceName, 1 );
  14.130 +    return aSeq;
  14.131 +}
  14.132 +
  14.133 +uno::Reference< uno::XInterface > SAL_CALL RtfImport_createInstance(const uno::Reference< lang::XMultiServiceFactory > & rSMgr ) throw( uno::Exception )
  14.134 +{
  14.135 +    return (cppu::OWeakObject*) new RtfImportFilter( rSMgr );
  14.136 +}
  14.137 +
  14.138 +/* vi:set shiftwidth=4 expandtab: */
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/sw/source/filter/ww8/rtfimportfilter.hxx	Thu Jul 29 22:01:25 2010 +0200
    15.3 @@ -0,0 +1,75 @@
    15.4 +/*************************************************************************
    15.5 + *
    15.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    15.7 + *
    15.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    15.9 + * Copyright 2010 Miklos Vajna.
   15.10 + *
   15.11 + * OpenOffice.org - a multi-platform office productivity suite
   15.12 + *
   15.13 + * This file is part of OpenOffice.org.
   15.14 + *
   15.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   15.16 + * it under the terms of the GNU Lesser General Public License version 3
   15.17 + * only, as published by the Free Software Foundation.
   15.18 + *
   15.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   15.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   15.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15.22 + * GNU Lesser General Public License version 3 for more details
   15.23 + * (a copy is included in the LICENSE file that accompanied this code).
   15.24 + *
   15.25 + * You should have received a copy of the GNU Lesser General Public License
   15.26 + * version 3 along with OpenOffice.org.  If not, see
   15.27 + * <http://www.openoffice.org/license.html>
   15.28 + * for a copy of the LGPLv3 License.
   15.29 + *
   15.30 + ************************************************************************/
   15.31 +
   15.32 +#ifndef _RTFIMPORTFILTER_HXX_
   15.33 +#define _RTFIMPORTFILTER_HXX_
   15.34 +
   15.35 +#include <com/sun/star/document/XFilter.hpp>
   15.36 +#include <com/sun/star/document/XImporter.hpp>
   15.37 +#include <com/sun/star/uno/XComponentContext.hpp>
   15.38 +#include <cppuhelper/implbase2.hxx>
   15.39 +#include <tools/stream.hxx>
   15.40 +#include <shellio.hxx>
   15.41 +
   15.42 +/// The physical access to the RTF document (for reading).
   15.43 +class RtfImportFilter : public cppu::WeakImplHelper2
   15.44 +<
   15.45 +    com::sun::star::document::XFilter,
   15.46 +    com::sun::star::document::XImporter
   15.47 +>
   15.48 +{
   15.49 +protected:
   15.50 +    ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xMSF;
   15.51 +    ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > m_xDstDoc;
   15.52 +public:
   15.53 +    RtfImportFilter( const ::com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& xMSF );
   15.54 +    virtual ~RtfImportFilter();
   15.55 +
   15.56 +    // XFilter
   15.57 +    virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
   15.58 +        throw (::com::sun::star::uno::RuntimeException);
   15.59 +    virtual void SAL_CALL cancel(  )
   15.60 +        throw (::com::sun::star::uno::RuntimeException);
   15.61 +
   15.62 +    // XImporter
   15.63 +    virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
   15.64 +        throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
   15.65 +};
   15.66 +
   15.67 +::rtl::OUString RtfImport_getImplementationName();
   15.68 +::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL RtfImport_getSupportedServiceNames()
   15.69 +    throw();
   15.70 +::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL RtfImport_createInstance(
   15.71 +                                                                        const ::com::sun::star::uno::Reference<
   15.72 +                                                                        com::sun::star::lang::XMultiServiceFactory > &xMSF)
   15.73 +    throw( ::com::sun::star::uno::Exception );
   15.74 +
   15.75 +#define IMPL_NAME_RTFIMPORT "com.sun.star.comp.Writer.RtfImport"
   15.76 +
   15.77 +#endif // _RTFIMPORTFILTER_HXX_
   15.78 +/* vi:set shiftwidth=4 expandtab: */
    16.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.2 +++ b/sw/source/filter/ww8/rtfsdrexport.cxx	Thu Jul 29 22:01:25 2010 +0200
    16.3 @@ -0,0 +1,578 @@
    16.4 +/*************************************************************************
    16.5 + *
    16.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    16.7 + *
    16.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    16.9 + * Copyright 2010 Miklos Vajna.
   16.10 + *
   16.11 + * OpenOffice.org - a multi-platform office productivity suite
   16.12 + *
   16.13 + * This file is part of OpenOffice.org.
   16.14 + *
   16.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   16.16 + * it under the terms of the GNU Lesser General Public License version 3
   16.17 + * only, as published by the Free Software Foundation.
   16.18 + *
   16.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   16.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   16.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16.22 + * GNU Lesser General Public License version 3 for more details
   16.23 + * (a copy is included in the LICENSE file that accompanied this code).
   16.24 + *
   16.25 + * You should have received a copy of the GNU Lesser General Public License
   16.26 + * version 3 along with OpenOffice.org.  If not, see
   16.27 + * <http://www.openoffice.org/license.html>
   16.28 + * for a copy of the LGPLv3 License.
   16.29 + *
   16.30 + ************************************************************************/
   16.31 +
   16.32 +#include "rtfsdrexport.hxx"
   16.33 +#include "rtfexport.hxx"
   16.34 +#include "writerhelper.hxx"
   16.35 +
   16.36 +#include <com/sun/star/i18n/ScriptType.hdl>
   16.37 +#include <osl/diagnose.h>
   16.38 +#include <rtl/strbuf.hxx>
   16.39 +#include <rtl/ustring.hxx>
   16.40 +#include <svtools/itemiter.hxx>
   16.41 +#include <svtools/rtfkeywd.hxx>
   16.42 +#include <svx/editdata.hxx>
   16.43 +#include <svx/editobj.hxx>
   16.44 +#include <svx/flditem.hxx>
   16.45 +#include <svx/fontitem.hxx>
   16.46 +#include <svx/svdotext.hxx>
   16.47 +#include <tools/stream.hxx>
   16.48 +#include <breakit.hxx>
   16.49 +
   16.50 +using rtl::OString;
   16.51 +using rtl::OStringBuffer;
   16.52 +using rtl::OUString;
   16.53 +using rtl::OUStringBuffer;
   16.54 +using namespace sw::util;
   16.55 +
   16.56 +/// Implementation of an empty stream that silently succeeds, but does nothing.
   16.57 +///
   16.58 +/// In fact, this is a hack.  The right solution is to abstract EscherEx to be
   16.59 +/// able to work without SvStream; but at the moment it is better to live with
   16.60 +/// this I guess.
   16.61 +class SvNullStream : public SvStream
   16.62 +{
   16.63 +protected:
   16.64 +    virtual sal_Size GetData( void* pData, sal_Size nSize ) { memset( pData, 0, nSize ); return nSize; }
   16.65 +    virtual sal_Size PutData( const void*, sal_Size nSize ) { return nSize; }
   16.66 +    virtual sal_Size SeekPos( sal_Size nPos ) { return nPos; }
   16.67 +    virtual void SetSize( sal_Size ) {}
   16.68 +    virtual void FlushData() {}
   16.69 +
   16.70 +public:
   16.71 +    SvNullStream() : SvStream() {}
   16.72 +    virtual ~SvNullStream() {}
   16.73 +};
   16.74 +
   16.75 +RtfSdrExport::RtfSdrExport( RtfExport &rExport )
   16.76 +    : EscherEx( *( new SvNullStream ), 0 ),
   16.77 +      m_rExport( rExport ),
   16.78 +      m_rAttrOutput( (RtfAttributeOutput&)m_rExport.AttrOutput() ),
   16.79 +      m_nShapeType( ESCHER_ShpInst_Nil ),
   16.80 +      m_pShapeStyle( new OStringBuffer( 200 ) ),
   16.81 +      m_pShapeTypeWritten( new bool[ ESCHER_ShpInst_COUNT ] )
   16.82 +{
   16.83 +    mnGroupLevel = 1;
   16.84 +    memset( m_pShapeTypeWritten, 0, ESCHER_ShpInst_COUNT * sizeof( bool ) );
   16.85 +}
   16.86 +
   16.87 +RtfSdrExport::~RtfSdrExport()
   16.88 +{
   16.89 +    delete mpOutStrm, mpOutStrm = NULL;
   16.90 +    delete m_pShapeStyle, m_pShapeStyle = NULL;
   16.91 +    delete[] m_pShapeTypeWritten, m_pShapeTypeWritten = NULL;
   16.92 +}
   16.93 +
   16.94 +void RtfSdrExport::OpenContainer( UINT16 nEscherContainer, int nRecInstance )
   16.95 +{
   16.96 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
   16.97 +
   16.98 +    EscherEx::OpenContainer( nEscherContainer, nRecInstance );
   16.99 +
  16.100 +    if ( nEscherContainer == ESCHER_SpContainer )
  16.101 +    {
  16.102 +        m_nShapeType = ESCHER_ShpInst_Nil;
  16.103 +        if ( m_pShapeStyle->getLength() )
  16.104 +            m_pShapeStyle->makeStringAndClear();
  16.105 +        m_pShapeStyle->ensureCapacity( 200 );
  16.106 +        m_aShapeProps.clear();
  16.107 +    }
  16.108 +}
  16.109 +
  16.110 +void RtfSdrExport::CloseContainer()
  16.111 +{
  16.112 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.113 +
  16.114 +    if ( mRecTypes.back() == ESCHER_SpContainer )
  16.115 +    {
  16.116 +        // write the shape now when we have all the info
  16.117 +        sal_Int32 nShapeElement = StartShape();
  16.118 +        EndShape( nShapeElement );
  16.119 +
  16.120 +        // cleanup
  16.121 +        m_nShapeType = ESCHER_ShpInst_Nil;
  16.122 +    }
  16.123 +
  16.124 +    EscherEx::CloseContainer();
  16.125 +}
  16.126 +
  16.127 +UINT32 RtfSdrExport::EnterGroup( const String& /*rShapeName*/, const Rectangle* /*pRect*/ )
  16.128 +{
  16.129 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.130 +
  16.131 +    return GetShapeID();
  16.132 +}
  16.133 +
  16.134 +void RtfSdrExport::LeaveGroup()
  16.135 +{
  16.136 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.137 +
  16.138 +    /* noop */
  16.139 +}
  16.140 +
  16.141 +void RtfSdrExport::AddShape( UINT32 nShapeType, UINT32 nShapeFlags, UINT32 /*nShapeId*/ )
  16.142 +{
  16.143 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.144 +
  16.145 +    m_nShapeType = nShapeType;
  16.146 +    m_nShapeFlags = nShapeFlags;
  16.147 +}
  16.148 +
  16.149 +inline sal_uInt16 impl_GetUInt16( const sal_uInt8* &pVal )
  16.150 +{
  16.151 +    sal_uInt16 nRet = *pVal++;
  16.152 +    nRet += ( *pVal++ ) << 8;
  16.153 +    return nRet;
  16.154 +}
  16.155 +
  16.156 +inline sal_Int32 impl_GetPointComponent( const sal_uInt8* &pVal, sal_uInt16 nPointSize )
  16.157 +{
  16.158 +    sal_Int32 nRet = 0;
  16.159 +    if ( ( nPointSize == 0xfff0 ) || ( nPointSize == 4 ) )
  16.160 +    {
  16.161 +        sal_uInt16 nUnsigned = *pVal++;
  16.162 +        nUnsigned += ( *pVal++ ) << 8;
  16.163 +
  16.164 +        nRet = sal_Int16( nUnsigned );
  16.165 +    }
  16.166 +    else if ( nPointSize == 8 )
  16.167 +    {
  16.168 +        sal_uInt32 nUnsigned = *pVal++;
  16.169 +        nUnsigned += ( *pVal++ ) << 8;
  16.170 +        nUnsigned += ( *pVal++ ) << 16;
  16.171 +        nUnsigned += ( *pVal++ ) << 24;
  16.172 +
  16.173 +        nRet = nUnsigned;
  16.174 +    }
  16.175 +    
  16.176 +    return nRet;
  16.177 +}
  16.178 +
  16.179 +void RtfSdrExport::Commit( EscherPropertyContainer& rProps, const Rectangle& rRect )
  16.180 +{
  16.181 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.182 +
  16.183 +    if ( m_nShapeType == ESCHER_ShpInst_Nil )
  16.184 +        return;
  16.185 +
  16.186 +    if ( m_nShapeType == ESCHER_ShpInst_Line )
  16.187 +        AddLineDimensions( rRect );
  16.188 +    else
  16.189 +        AddRectangleDimensions( *m_pShapeStyle, rRect );
  16.190 +
  16.191 +    // properties
  16.192 +    const EscherProperties &rOpts = rProps.GetOpts();
  16.193 +    for ( EscherProperties::const_iterator it = rOpts.begin(); it != rOpts.end(); ++it )
  16.194 +    {
  16.195 +        sal_uInt16 nId = ( it->nPropId & 0x0FFF );
  16.196 +
  16.197 +        switch ( nId )
  16.198 +        {
  16.199 +            case ESCHER_Prop_WrapText:
  16.200 +                {
  16.201 +                    int nWrapType = 0;
  16.202 +                    switch ( it->nPropValue )
  16.203 +                    {
  16.204 +                        case ESCHER_WrapSquare:    nWrapType = 2; break;
  16.205 +                        case ESCHER_WrapByPoints:  nWrapType = 4; break;
  16.206 +                        case ESCHER_WrapNone:      nWrapType = 3; break;
  16.207 +                        case ESCHER_WrapTopBottom: nWrapType = 1; break;
  16.208 +                        case ESCHER_WrapThrough:   nWrapType = 5; break;
  16.209 +                    }
  16.210 +                    if ( nWrapType )
  16.211 +                        m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPWR).append((sal_Int32)nWrapType);
  16.212 +                }
  16.213 +                break;
  16.214 +            case ESCHER_Prop_fillColor:
  16.215 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("fillColor"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.216 +                break;
  16.217 +            case ESCHER_Prop_fillBackColor:
  16.218 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("fillBackColor"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.219 +                break;
  16.220 +            case ESCHER_Prop_AnchorText:
  16.221 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("anchorText"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.222 +                break;
  16.223 +            case ESCHER_Prop_fNoFillHitTest:
  16.224 +                if (it->nPropValue)
  16.225 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("fNoFillHitTest"), OString::valueOf(sal_Int32(1))));
  16.226 +                break;
  16.227 +            case ESCHER_Prop_fNoLineDrawDash:
  16.228 +                if (it->nPropValue)
  16.229 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("fNoLineDrawDash"), OString::valueOf(sal_Int32(1))));
  16.230 +                break;
  16.231 +            case ESCHER_Prop_lineColor:
  16.232 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("lineColor"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.233 +                break;
  16.234 +            case ESCHER_Prop_lineBackColor:
  16.235 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("lineBackColor"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.236 +                break;
  16.237 +            case ESCHER_Prop_lineJoinStyle:
  16.238 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("lineJoinStyle"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.239 +                break;
  16.240 +            case ESCHER_Prop_fshadowObscured:
  16.241 +                if (it->nPropValue)
  16.242 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("fshadowObscured"), OString::valueOf(sal_Int32(1))));
  16.243 +                break;
  16.244 +            case ESCHER_Prop_geoLeft:
  16.245 +            case ESCHER_Prop_geoTop:
  16.246 +                {
  16.247 +                    sal_uInt32 nLeft = 0, nTop = 0;
  16.248 +
  16.249 +                    if ( nId == ESCHER_Prop_geoLeft )
  16.250 +                    {
  16.251 +                        nLeft = it->nPropValue;
  16.252 +                        rProps.GetOpt( ESCHER_Prop_geoTop, nTop );
  16.253 +                    }
  16.254 +                    else
  16.255 +                    {
  16.256 +                        nTop = it->nPropValue;
  16.257 +                        rProps.GetOpt( ESCHER_Prop_geoLeft, nLeft );
  16.258 +                    }
  16.259 +
  16.260 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("geoLeft"),
  16.261 +                                OString::valueOf(sal_Int32(sal_Int32( nLeft )))));
  16.262 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("geoTop"),
  16.263 +                                OString::valueOf(sal_Int32(sal_Int32( nTop )))));
  16.264 +                }
  16.265 +                break;
  16.266 +
  16.267 +            case ESCHER_Prop_geoRight:
  16.268 +            case ESCHER_Prop_geoBottom:
  16.269 +                {
  16.270 +                    sal_uInt32 nLeft = 0, nRight = 0, nTop = 0, nBottom = 0;
  16.271 +                    rProps.GetOpt( ESCHER_Prop_geoLeft, nLeft );
  16.272 +                    rProps.GetOpt( ESCHER_Prop_geoTop, nTop );
  16.273 +
  16.274 +                    if ( nId == ESCHER_Prop_geoRight )
  16.275 +                    {
  16.276 +                        nRight = it->nPropValue;
  16.277 +                        rProps.GetOpt( ESCHER_Prop_geoBottom, nBottom );
  16.278 +                    }
  16.279 +                    else
  16.280 +                    {
  16.281 +                        nBottom = it->nPropValue;
  16.282 +                        rProps.GetOpt( ESCHER_Prop_geoRight, nRight );
  16.283 +                    }
  16.284 +
  16.285 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("geoRight"),
  16.286 +                                OString::valueOf(sal_Int32(sal_Int32( nRight ) - sal_Int32( nLeft )))));
  16.287 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("geoBottom"),
  16.288 +                                OString::valueOf(sal_Int32(sal_Int32( nBottom ) - sal_Int32( nTop )))));
  16.289 +                }
  16.290 +                break;
  16.291 +            case ESCHER_Prop_pVertices:
  16.292 +            case ESCHER_Prop_pSegmentInfo:
  16.293 +                {
  16.294 +                    EscherPropSortStruct aVertices;
  16.295 +                    EscherPropSortStruct aSegments;
  16.296 +
  16.297 +                    if ( rProps.GetOpt( ESCHER_Prop_pVertices, aVertices ) &&
  16.298 +                         rProps.GetOpt( ESCHER_Prop_pSegmentInfo, aSegments ) )
  16.299 +                    {
  16.300 +                        const sal_uInt8 *pVerticesIt = aVertices.pBuf + 6;
  16.301 +                        const sal_uInt8 *pSegmentIt = aSegments.pBuf;
  16.302 +
  16.303 +                        OStringBuffer aSegmentInfo( 512 );
  16.304 +                        OStringBuffer aVerticies( 512 );
  16.305 +
  16.306 +                        sal_uInt16 nPointSize = aVertices.pBuf[4] + ( aVertices.pBuf[5] << 8 );
  16.307 +
  16.308 +                        // number of segments
  16.309 +                        sal_uInt16 nSegments = impl_GetUInt16( pSegmentIt );
  16.310 +                        sal_Int32 nVertices = 0;
  16.311 +                        aSegmentInfo.append("2;").append((sal_Int32)nSegments);
  16.312 +                        pSegmentIt += 4;
  16.313 +
  16.314 +                        for ( ; nSegments; --nSegments )
  16.315 +                        {
  16.316 +                            sal_uInt16 nSeg = impl_GetUInt16( pSegmentIt );
  16.317 +                            aSegmentInfo.append(';').append((sal_Int32)nSeg);
  16.318 +                            switch ( nSeg )
  16.319 +                            {
  16.320 +                                case 0x0001: // lineto
  16.321 +                                case 0x4000: // moveto
  16.322 +                                    {
  16.323 +                                        sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nPointSize );
  16.324 +                                        sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nPointSize );
  16.325 +                                        aVerticies.append( ";(" ).append( nX ).append( "," ).append( nY ).append( ")" );
  16.326 +                                        nVertices ++;
  16.327 +                                    }
  16.328 +                                    break;
  16.329 +                                case 0x2001: // curveto
  16.330 +                                    {
  16.331 +                                        for (int i = 0; i < 3; i++)
  16.332 +                                        {
  16.333 +                                            sal_Int32 nX = impl_GetPointComponent( pVerticesIt, nPointSize );
  16.334 +                                            sal_Int32 nY = impl_GetPointComponent( pVerticesIt, nPointSize );
  16.335 +                                            aVerticies.append( ";(" ).append( nX ).append( "," ).append( nY ).append( ")" );
  16.336 +                                            nVertices ++;
  16.337 +                                        }
  16.338 +                                    }
  16.339 +                                    break;
  16.340 +                                case 0xb300:
  16.341 +                                case 0xac00:
  16.342 +                                case 0xaa00: // nofill
  16.343 +                                case 0xab00: // nostroke
  16.344 +                                case 0x6001: // close
  16.345 +                                case 0x8000: // end
  16.346 +                                    break;
  16.347 +                                default:
  16.348 +                                    OSL_TRACE("%s: unhandled segment '%x' in the path", __PRETTY_FUNCTION__, nSeg);
  16.349 +                                    break;
  16.350 +                            }
  16.351 +                        }
  16.352 +                        
  16.353 +                        if (aVerticies.getLength() )
  16.354 +                        {
  16.355 +                            // We know the number of vertices at the end only, so we have to prepend them here.
  16.356 +                            OStringBuffer aBuf;
  16.357 +                            aBuf.append("8;").append((sal_Int32)nVertices);
  16.358 +                            aBuf.append(aVerticies.makeStringAndClear());
  16.359 +                            m_aShapeProps.insert(std::pair<OString,OString>(OString("pVerticies"), aBuf.makeStringAndClear()));
  16.360 +                        }
  16.361 +                        if ( aSegmentInfo.getLength() )
  16.362 +                            m_aShapeProps.insert(std::pair<OString,OString>(OString("pSegmentInfo"), aSegmentInfo.makeStringAndClear()));
  16.363 +                    }
  16.364 +                    else
  16.365 +                        OSL_TRACE("%s: unhandled shape path, missing either pVertices or pSegmentInfo", __PRETTY_FUNCTION__);
  16.366 +                }
  16.367 +                break;
  16.368 +            case ESCHER_Prop_shapePath:
  16.369 +                // noop, we use pSegmentInfo instead
  16.370 +                break;
  16.371 +            case ESCHER_Prop_fFillOK:
  16.372 +                if (!it->nPropValue)
  16.373 +                    m_aShapeProps.insert(std::pair<OString,OString>(OString("fFillOK"), OString::valueOf(sal_Int32(0))));
  16.374 +                break;
  16.375 +            case ESCHER_Prop_dxTextLeft:
  16.376 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("dxTextLeft"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.377 +                break;
  16.378 +            case ESCHER_Prop_dyTextTop:
  16.379 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("dyTextTop"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.380 +                break;
  16.381 +            case ESCHER_Prop_dxTextRight:
  16.382 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("dxTextRight"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.383 +                break;
  16.384 +            case ESCHER_Prop_dyTextBottom:
  16.385 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("dyTextBottom"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.386 +                break;
  16.387 +            case ESCHER_Prop_FitTextToShape:
  16.388 +                // Size text to fit shape size: not supported by RTF
  16.389 +                break;
  16.390 +            case ESCHER_Prop_adjustValue:
  16.391 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("adjustValue"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.392 +                break;
  16.393 +            case ESCHER_Prop_txflTextFlow:
  16.394 +                m_aShapeProps.insert(std::pair<OString,OString>(OString("txflTextFlow"), OString::valueOf(sal_Int32(it->nPropValue))));
  16.395 +                break;
  16.396 +            default:
  16.397 +                OSL_TRACE("%s: unhandled property: %d (value: %d)", __PRETTY_FUNCTION__, nId, it->nPropValue);
  16.398 +                break;
  16.399 +        }
  16.400 +    }
  16.401 +}
  16.402 +
  16.403 +void RtfSdrExport::AddLineDimensions( const Rectangle& rRectangle )
  16.404 +{
  16.405 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.406 +
  16.407 +    // We get the position relative to (the current?) character
  16.408 +    m_aShapeProps.insert(std::pair<OString,OString>(OString("posrelh"), OString::valueOf(sal_Int32(3))));
  16.409 +
  16.410 +    switch ( m_nShapeFlags & 0xC0 )
  16.411 +    {
  16.412 +        case 0x40:
  16.413 +            m_aShapeProps.insert(std::pair<OString,OString>(OString("fFlipV"), OString::valueOf(sal_Int32(1))));
  16.414 +            break;
  16.415 +        case 0x80:
  16.416 +            m_aShapeProps.insert(std::pair<OString,OString>(OString("fFlipH"), OString::valueOf(sal_Int32(1))));
  16.417 +            break;
  16.418 +        case 0xC0:
  16.419 +            m_aShapeProps.insert(std::pair<OString,OString>(OString("fFlipV"), OString::valueOf(sal_Int32(1))));
  16.420 +            m_aShapeProps.insert(std::pair<OString,OString>(OString("fFlipH"), OString::valueOf(sal_Int32(1))));
  16.421 +            break;
  16.422 +    }
  16.423 +
  16.424 +    // the actual dimensions
  16.425 +    m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPLEFT).append(rRectangle.Left());
  16.426 +    m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPTOP).append(rRectangle.Top());
  16.427 +    m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT).append(rRectangle.Right());
  16.428 +    m_pShapeStyle->append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM).append(rRectangle.Bottom());
  16.429 +}
  16.430 +
  16.431 +void RtfSdrExport::AddRectangleDimensions( rtl::OStringBuffer& rBuffer, const Rectangle& rRectangle )
  16.432 +{
  16.433 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.434 +
  16.435 +    // We get the position relative to (the current?) character
  16.436 +    m_aShapeProps.insert(std::pair<OString,OString>(OString("posrelh"), OString::valueOf(sal_Int32(3))));
  16.437 +
  16.438 +    rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPLEFT).append(rRectangle.Left());
  16.439 +    rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPTOP).append(rRectangle.Top());
  16.440 +    rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPRIGHT).append(rRectangle.Right());
  16.441 +    rBuffer.append(OOO_STRING_SVTOOLS_RTF_SHPBOTTOM).append(rRectangle.Bottom());
  16.442 +}
  16.443 +
  16.444 +void RtfSdrExport::AddShapeAttribute( sal_Int32 /*nAttribute*/, const rtl::OString& /*rValue*/ )
  16.445 +{
  16.446 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.447 +
  16.448 +    /* noop */
  16.449 +}
  16.450 +
  16.451 +extern const char* pShapeTypes[];
  16.452 +
  16.453 +sal_Int32 RtfSdrExport::StartShape()
  16.454 +{
  16.455 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.456 +
  16.457 +    if ( m_nShapeType == ESCHER_ShpInst_Nil )
  16.458 +        return -1;
  16.459 +
  16.460 +    m_aShapeProps.insert(std::pair<OString,OString>(OString("shapeType"), OString::valueOf(sal_Int32(m_nShapeType))));
  16.461 +
  16.462 +    m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHP);
  16.463 +    m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_IGNORE).append(OOO_STRING_SVTOOLS_RTF_SHPINST);
  16.464 +
  16.465 +    m_rAttrOutput.RunText().append(m_pShapeStyle->makeStringAndClear());
  16.466 +    // Ignore \shpbxpage, \shpbxmargin, and \shpbxcolumn, in favor of the posrelh property.
  16.467 +    m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBXIGNORE);
  16.468 +    // Ignore \shpbypage, \shpbymargin, and \shpbycolumn, in favor of the posrelh property.
  16.469 +    m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_SHPBYIGNORE);
  16.470 +
  16.471 +    for(std::map<OString,OString>::reverse_iterator i = m_aShapeProps.rbegin(); i != m_aShapeProps.rend(); i++)
  16.472 +        m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SP)
  16.473 +            .append('{').append(OOO_STRING_SVTOOLS_RTF_SN " ").append((*i).first).append('}')
  16.474 +            .append('{').append(OOO_STRING_SVTOOLS_RTF_SV " ").append((*i).second).append('}')
  16.475 +            .append('}');
  16.476 +
  16.477 +    // now check if we have some text
  16.478 +    const SdrTextObj* pTxtObj = PTR_CAST(SdrTextObj, m_pSdrObject);
  16.479 +    if (pTxtObj)
  16.480 +    {
  16.481 +        const OutlinerParaObject* pParaObj = 0;
  16.482 +        bool bOwnParaObj = false;
  16.483 +
  16.484 +        /*
  16.485 +        #i13885#
  16.486 +        When the object is actively being edited, that text is not set into
  16.487 +        the objects normal text object, but lives in a seperate object.
  16.488 +        */
  16.489 +        if (pTxtObj->IsTextEditActive())
  16.490 +        {
  16.491 +            pParaObj = pTxtObj->GetEditOutlinerParaObject();
  16.492 +            bOwnParaObj = true;
  16.493 +        }
  16.494 +        else
  16.495 +        {
  16.496 +            pParaObj = pTxtObj->GetOutlinerParaObject();
  16.497 +        }
  16.498 +
  16.499 +        if( pParaObj )
  16.500 +        {
  16.501 +            // this is reached only in case some text is attached to the shape
  16.502 +            WriteOutliner(*pParaObj);
  16.503 +            if( bOwnParaObj )
  16.504 +                delete pParaObj;
  16.505 +        }
  16.506 +    }
  16.507 +
  16.508 +    return m_nShapeType;
  16.509 +}
  16.510 +
  16.511 +void RtfSdrExport::WriteOutliner(const OutlinerParaObject& rParaObj)
  16.512 +{
  16.513 +    OSL_TRACE("%s start", __PRETTY_FUNCTION__);
  16.514 +
  16.515 +    const EditTextObject& rEditObj = rParaObj.GetTextObject();
  16.516 +    MSWord_SdrAttrIter aAttrIter( m_rExport, rEditObj, TXT_HFTXTBOX );
  16.517 +
  16.518 +    USHORT nPara = rEditObj.GetParagraphCount();
  16.519 +
  16.520 +    m_rAttrOutput.RunText().append('{').append(OOO_STRING_SVTOOLS_RTF_SHPTXT).append(' ');
  16.521 +    for (USHORT n = 0; n < nPara; ++n)
  16.522 +    {
  16.523 +        if( n )
  16.524 +            aAttrIter.NextPara( n );
  16.525 +
  16.526 +        rtl_TextEncoding eChrSet = aAttrIter.GetNodeCharSet();
  16.527 +
  16.528 +        String aStr( rEditObj.GetText( n ));
  16.529 +        xub_StrLen nAktPos = 0;
  16.530 +        xub_StrLen nEnd = aStr.Len();
  16.531 +        
  16.532 +        aAttrIter.OutParaAttr(false);
  16.533 +        m_rAttrOutput.RunText().append(m_rAttrOutput.Styles().makeStringAndClear());
  16.534 +
  16.535 +        do {
  16.536 +            xub_StrLen nNextAttr = aAttrIter.WhereNext();
  16.537 +            rtl_TextEncoding eNextChrSet = aAttrIter.GetNextCharSet();
  16.538 +
  16.539 +            if( nNextAttr > nEnd )
  16.540 +                nNextAttr = nEnd;
  16.541 +
  16.542 +            aAttrIter.OutAttr( nAktPos );
  16.543 +            m_rAttrOutput.RunText().append('{').append(m_rAttrOutput.Styles().makeStringAndClear()).append(m_rExport.sNewLine);
  16.544 +            bool bTxtAtr = aAttrIter.IsTxtAttr( nAktPos );
  16.545 +            if( !bTxtAtr )
  16.546 +            {
  16.547 +                String aOut( aStr.Copy( nAktPos, nNextAttr - nAktPos ) );
  16.548 +                m_rAttrOutput.RunText().append( m_rExport.OutString( aOut, eChrSet ) );
  16.549 +            }
  16.550 +
  16.551 +            m_rAttrOutput.RunText().append('}');
  16.552 +
  16.553 +            nAktPos = nNextAttr;
  16.554 +            eChrSet = eNextChrSet;
  16.555 +            aAttrIter.NextPos();
  16.556 +        }
  16.557 +        while( nAktPos < nEnd );
  16.558 +    }
  16.559 +    m_rAttrOutput.RunText().append(OOO_STRING_SVTOOLS_RTF_PAR).append('}');
  16.560 +
  16.561 +    OSL_TRACE("%s end", __PRETTY_FUNCTION__);
  16.562 +}
  16.563 +
  16.564 +void RtfSdrExport::EndShape( sal_Int32 nShapeElement )
  16.565 +{
  16.566 +    OSL_TRACE("%s", __PRETTY_FUNCTION__);
  16.567 +
  16.568 +    if ( nShapeElement >= 0 )
  16.569 +    {
  16.570 +        // end of the shape
  16.571 +        m_rAttrOutput.RunText().append('}').append('}');
  16.572 +    }
  16.573 +}
  16.574 +
  16.575 +UINT32 RtfSdrExport::AddSdrObject( const SdrObject& rObj )
  16.576 +{
  16.577 +    m_pSdrObject = &rObj;
  16.578 +    return EscherEx::AddSdrObject(rObj);
  16.579 +}
  16.580 +
  16.581 +/* vi:set shiftwidth=4 expandtab: */
    17.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.2 +++ b/sw/source/filter/ww8/rtfsdrexport.hxx	Thu Jul 29 22:01:25 2010 +0200
    17.3 @@ -0,0 +1,112 @@
    17.4 +/*************************************************************************
    17.5 + *
    17.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    17.7 + *
    17.8 + * Copyright 2000, 2010 Oracle and/or its affiliates.
    17.9 + * Copyright 2010 Miklos Vajna.
   17.10 + *
   17.11 + * OpenOffice.org - a multi-platform office productivity suite
   17.12 + *
   17.13 + * This file is part of OpenOffice.org.
   17.14 + *
   17.15 + * OpenOffice.org is free software: you can redistribute it and/or modify
   17.16 + * it under the terms of the GNU Lesser General Public License version 3
   17.17 + * only, as published by the Free Software Foundation.
   17.18 + *
   17.19 + * OpenOffice.org is distributed in the hope that it will be useful,
   17.20 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
   17.21 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   17.22 + * GNU Lesser General Public License version 3 for more details
   17.23 + * (a copy is included in the LICENSE file that accompanied this code).
   17.24 + *
   17.25 + * You should have received a copy of the GNU Lesser General Public License
   17.26 + * version 3 along with OpenOffice.org.  If not, see
   17.27 + * <http://www.openoffice.org/license.html>
   17.28 + * for a copy of the LGPLv3 License.
   17.29 + *
   17.30 + ************************************************************************/
   17.31 +
   17.32 +#ifndef _RTFSdrEXPORT_HXX_
   17.33 +#define _RTFSdrEXPORT_HXX_
   17.34 +
   17.35 +#include <svx/escherex.hxx>
   17.36 +#include <svx/outlobj.hxx>
   17.37 +#include <rtl/strbuf.hxx>
   17.38 +
   17.39 +#include <map>
   17.40 +
   17.41 +class RtfExport;
   17.42 +class RtfAttributeOutput;
   17.43 +
   17.44 +class RtfSdrExport : public EscherEx
   17.45 +{
   17.46 +    RtfExport &m_rExport;
   17.47 +
   17.48 +    RtfAttributeOutput &m_rAttrOutput;
   17.49 +
   17.50 +    const SdrObject* m_pSdrObject;
   17.51 +
   17.52 +    /// Remember the shape type.
   17.53 +    sal_uInt32 m_nShapeType;
   17.54 +    
   17.55 +    /// Remember the shape flags.
   17.56 +    sal_uInt32 m_nShapeFlags;
   17.57 +
   17.58 +    /// Remember style, the most important shape attribute ;-)
   17.59 +    rtl::OStringBuffer *m_pShapeStyle;
   17.60 +
   17.61 +    std::map<rtl::OString,rtl::OString> m_aShapeProps;
   17.62 +
   17.63 +    /// Remember which shape types we had already written.
   17.64 +    bool *m_pShapeTypeWritten;
   17.65 +
   17.66 +public:
   17.67 +                        RtfSdrExport( RtfExport &rExport );
   17.68 +    virtual             ~RtfSdrExport();
   17.69 +
   17.70 +    /// Export the sdr object as Sdr.
   17.71 +    ///
   17.72 +    /// Call this when you need to export the object as Sdr in RTF.
   17.73 +    UINT32 AddSdrObject( const SdrObject& rObj );
   17.74 +
   17.75 +protected:
   17.76 +    /// Add an attribute to the generated shape element.
   17.77 +    ///
   17.78 +    /// This should be called from within StartShape() to ensure that the
   17.79 +    /// added attribute is preserved.
   17.80 +    void                AddShapeAttribute( sal_Int32 nAttribute, const rtl::OString& sValue );
   17.81 +
   17.82 +    /// Start the shape for which we just collected the information.
   17.83 +    ///
   17.84 +    /// Returns the element's tag number, -1 means we wrote nothing.
   17.85 +    virtual sal_Int32   StartShape();
   17.86 +
   17.87 +    /// End the shape.
   17.88 +    ///
   17.89 +    /// The parameter is just what we got from StartShape().
   17.90 +    virtual void        EndShape( sal_Int32 nShapeElement );
   17.91 +
   17.92 +    virtual void        Commit( EscherPropertyContainer& rProps, const Rectangle& rRect );
   17.93 +
   17.94 +private:
   17.95 +
   17.96 +    virtual void OpenContainer( UINT16 nEscherContainer, int nRecInstance = 0 );
   17.97 +    virtual void CloseContainer();
   17.98 +
   17.99 +    virtual UINT32 EnterGroup( const String& rShapeName, const Rectangle* pBoundRect = 0 );
  17.100 +    virtual void LeaveGroup();
  17.101 +
  17.102 +    virtual void AddShape( UINT32 nShapeType, UINT32 nShapeFlags, UINT32 nShapeId = 0 );
  17.103 +
  17.104 +private:
  17.105 +    /// Add starting and ending point of a line to the m_pShapeAttrList.
  17.106 +    void AddLineDimensions( const Rectangle& rRectangle );
  17.107 +
  17.108 +    /// Add position and size to the OStringBuffer.
  17.109 +    void AddRectangleDimensions( rtl::OStringBuffer& rBuffer, const Rectangle& rRectangle );
  17.110 +
  17.111 +    void WriteOutliner(const OutlinerParaObject& rParaObj);
  17.112 +};
  17.113 +
  17.114 +#endif // _RTFSdrEXPORT_HXX_
  17.115 +/* vi:set shiftwidth=4 expandtab: */
    18.1 --- a/sw/source/filter/ww8/wrtw8esh.cxx	Thu Jul 29 20:08:54 2010 +0200
    18.2 +++ b/sw/source/filter/ww8/wrtw8esh.cxx	Thu Jul 29 22:01:25 2010 +0200
    18.3 @@ -811,49 +811,7 @@
    18.4          OutputField(0, ww::eSHAPE, aEmptyStr, WRITEFIELD_CLOSE);
    18.5  }
    18.6  
    18.7 -class WW8_SdrAttrIter : public MSWordAttrIter
    18.8 -{
    18.9 -private:
   18.10 -    const EditTextObject* pEditObj;
   18.11 -    const SfxItemPool* pEditPool;
   18.12 -    EECharAttribArray aTxtAtrArr;
   18.13 -    SvPtrarr aChrTxtAtrArr;
   18.14 -    SvUShorts aChrSetArr;
   18.15 -    USHORT nPara;
   18.16 -    xub_StrLen nAktSwPos;
   18.17 -    xub_StrLen nTmpSwPos;                   // fuer HasItem()
   18.18 -    rtl_TextEncoding eNdChrSet;
   18.19 -    USHORT nScript;
   18.20 -    BYTE mnTyp;
   18.21 -
   18.22 -    xub_StrLen SearchNext( xub_StrLen nStartPos );
   18.23 -    void SetCharSet(const EECharAttrib& rTxtAttr, bool bStart);
   18.24 -
   18.25 -    //No copying
   18.26 -    WW8_SdrAttrIter(const WW8_SdrAttrIter&);
   18.27 -    WW8_SdrAttrIter& operator=(const WW8_SdrAttrIter&);
   18.28 -public:
   18.29 -    WW8_SdrAttrIter( WW8Export& rWr, const EditTextObject& rEditObj,
   18.30 -        BYTE nType );
   18.31 -    void NextPara( USHORT nPar );
   18.32 -    void OutParaAttr(bool bCharAttr);
   18.33 -    void OutEEField(const SfxPoolItem& rHt);
   18.34 -
   18.35 -    bool IsTxtAttr(xub_StrLen nSwPos);
   18.36 -
   18.37 -    void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
   18.38 -
   18.39 -    void OutAttr( xub_StrLen nSwPos );
   18.40 -    virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const;
   18.41 -    virtual const SfxPoolItem& GetItem( USHORT nWhich ) const;
   18.42 -    bool OutAttrWithRange(xub_StrLen nPos);
   18.43 -    xub_StrLen WhereNext() const                { return nAktSwPos; }
   18.44 -    rtl_TextEncoding GetNextCharSet() const;
   18.45 -    rtl_TextEncoding GetNodeCharSet() const     { return eNdChrSet; }
   18.46 -};
   18.47 -
   18.48 -
   18.49 -WW8_SdrAttrIter::WW8_SdrAttrIter( WW8Export& rWr,
   18.50 +MSWord_SdrAttrIter::MSWord_SdrAttrIter( MSWordExportBase& rWr,
   18.51      const EditTextObject& rEditObj, BYTE nTyp )
   18.52      : MSWordAttrIter( rWr ), pEditObj(&rEditObj), pEditPool(0),
   18.53      aTxtAtrArr( 0, 4 ), aChrTxtAtrArr( 0, 4 ), aChrSetArr( 0, 4 ),
   18.54 @@ -862,7 +820,7 @@
   18.55      NextPara( 0 );
   18.56  }
   18.57  
   18.58 -void WW8_SdrAttrIter::NextPara( USHORT nPar )
   18.59 +void MSWord_SdrAttrIter::NextPara( USHORT nPar )
   18.60  {
   18.61      nPara = nPar;
   18.62      // Attributwechsel an Pos 0 wird ignoriert, da davon ausgegangen
   18.63 @@ -885,7 +843,7 @@
   18.64      nAktSwPos = SearchNext( 1 );
   18.65  }
   18.66  
   18.67 -rtl_TextEncoding WW8_SdrAttrIter::GetNextCharSet() const
   18.68 +rtl_TextEncoding MSWord_SdrAttrIter::GetNextCharSet() const
   18.69  {
   18.70      if( aChrSetArr.Count() )
   18.71          return (rtl_TextEncoding)aChrSetArr[ aChrSetArr.Count() - 1 ];
   18.72 @@ -893,7 +851,7 @@
   18.73  }
   18.74  
   18.75  // der erste Parameter in SearchNext() liefert zurueck, ob es ein TxtAtr ist.
   18.76 -xub_StrLen WW8_SdrAttrIter::SearchNext( xub_StrLen nStartPos )
   18.77 +xub_StrLen MSWord_SdrAttrIter::SearchNext( xub_StrLen nStartPos )
   18.78  {
   18.79      xub_StrLen nPos;
   18.80      xub_StrLen nMinPos = STRING_MAXLEN;
   18.81 @@ -932,7 +890,7 @@
   18.82      return nMinPos;
   18.83  }
   18.84  
   18.85 -void WW8_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
   18.86 +void MSWord_SdrAttrIter::SetCharSet(const EECharAttrib& rAttr, bool bStart)
   18.87  {
   18.88      void* p = 0;
   18.89      rtl_TextEncoding eChrSet;
   18.90 @@ -962,7 +920,7 @@
   18.91      }
   18.92  }
   18.93  
   18.94 -void WW8_SdrAttrIter::OutEEField(const SfxPoolItem& rHt)
   18.95 +void MSWord_SdrAttrIter::OutEEField(const SfxPoolItem& rHt)
   18.96  {
   18.97      const SvxFieldItem &rField = (const SvxFieldItem &)rHt;
   18.98      const SvxFieldData *pFld = rField.GetField();
   18.99 @@ -981,7 +939,7 @@
  18.100      }
  18.101  }
  18.102  
  18.103 -void WW8_SdrAttrIter::OutAttr( xub_StrLen nSwPos )
  18.104 +void MSWord_SdrAttrIter::OutAttr( xub_StrLen nSwPos )
  18.105  {
  18.106      OutParaAttr(true);
  18.107  
  18.108 @@ -1038,7 +996,7 @@
  18.109      }
  18.110  }
  18.111  
  18.112 -bool WW8_SdrAttrIter::IsTxtAttr(xub_StrLen nSwPos)
  18.113 +bool MSWord_SdrAttrIter::IsTxtAttr(xub_StrLen nSwPos)
  18.114  {
  18.115      for (USHORT i = 0; i < aTxtAtrArr.Count(); ++i)
  18.116      {
  18.117 @@ -1063,7 +1021,7 @@
  18.118  // Attribut-Anfangposition fragen kann.
  18.119  // Es koennen nur Attribute mit Ende abgefragt werden.
  18.120  // Es wird mit bDeep gesucht
  18.121 -const SfxPoolItem* WW8_SdrAttrIter::HasTextItem(USHORT nWhich) const
  18.122 +const SfxPoolItem* MSWord_SdrAttrIter::HasTextItem(USHORT nWhich) const
  18.123  {
  18.124      const SfxPoolItem* pRet = 0;
  18.125      nWhich = sw::hack::TransformWhichBetweenPools(*pEditPool,
  18.126 @@ -1088,7 +1046,7 @@
  18.127      return pRet;
  18.128  }
  18.129  
  18.130 -const SfxPoolItem& WW8_SdrAttrIter::GetItem( USHORT nWhich ) const
  18.131 +const SfxPoolItem& MSWord_SdrAttrIter::GetItem( USHORT nWhich ) const
  18.132  {
  18.133      using sw::hack::GetSetWhichFromSwDocWhich;
  18.134      const SfxPoolItem* pRet = HasTextItem(nWhich);
  18.135 @@ -1102,7 +1060,7 @@
  18.136      return *pRet;
  18.137  }
  18.138  
  18.139 -void WW8_SdrAttrIter::OutParaAttr(bool bCharAttr)
  18.140 +void MSWord_SdrAttrIter::OutParaAttr(bool bCharAttr)
  18.141  {
  18.142      SfxItemSet aSet( pEditObj->GetParaAttribs( nPara ));
  18.143      if( aSet.Count() )
  18.144 @@ -1175,7 +1133,7 @@
  18.145  {
  18.146      bool bAnyWrite = false;
  18.147      const EditTextObject& rEditObj = rParaObj.GetTextObject();
  18.148 -    WW8_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
  18.149 +    MSWord_SdrAttrIter aAttrIter( *this, rEditObj, nTyp );
  18.150  
  18.151      USHORT nPara = rEditObj.GetParagraphCount();
  18.152      BYTE bNul = 0;
    19.1 --- a/sw/source/filter/ww8/wrtw8nds.cxx	Thu Jul 29 20:08:54 2010 +0200
    19.2 +++ b/sw/source/filter/ww8/wrtw8nds.cxx	Thu Jul 29 22:01:25 2010 +0200
    19.3 @@ -1646,14 +1646,127 @@
    19.4      m_rWW8Export.pO->Remove( 0, m_rWW8Export.pO->Count() );
    19.5  }
    19.6  
    19.7 -xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& /*rNode*/, xub_StrLen /*nAktPos*/  )
    19.8 +xub_StrLen MSWordExportBase::GetNextPos( SwAttrIter* aAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos  )
    19.9  {
   19.10 -   return aAttrIter->WhereNext();
   19.11 +    // Get the bookmarks for the normal run
   19.12 +    xub_StrLen nNextPos = aAttrIter->WhereNext();
   19.13 +
   19.14 +    GetSortedBookmarks( rNode, nAktPos, nNextPos - nAktPos );
   19.15 +
   19.16 +    xub_StrLen nNextBookmark = nNextPos;
   19.17 +    NearestBookmark( nNextPos );
   19.18 +
   19.19 +    return std::min( nNextPos, nNextBookmark );
   19.20  }
   19.21  
   19.22 -void MSWordExportBase::UpdatePosition( SwAttrIter* aAttrIter, xub_StrLen /*nAktPos*/, xub_StrLen /*nEnd*/ )
   19.23 +void MSWordExportBase::UpdatePosition( SwAttrIter* aAttrIter, xub_StrLen nAktPos, xub_StrLen /*nEnd*/ )
   19.24  {
   19.25 -    aAttrIter->NextPos();
   19.26 +    xub_StrLen nNextPos;
   19.27 +
   19.28 +    // either no bookmark, or it is not at the current position
   19.29 +    if ( !NearestBookmark( nNextPos ) || nNextPos > nAktPos )
   19.30 +        aAttrIter->NextPos();
   19.31 +}
   19.32 +
   19.33 +bool MSWordExportBase::GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt,
   19.34 +                    xub_StrLen nEnd, IMarkVector& rArr )
   19.35 +{
   19.36 +    IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
   19.37 +    ULONG nNd = rNd.GetIndex( );
   19.38 +
   19.39 +    const sal_Int32 nMarks = pMarkAccess->getMarksCount();
   19.40 +    for ( sal_Int32 i = 0; i < nMarks; i++ )
   19.41 +    {
   19.42 +        IMark* pMark = ( pMarkAccess->getMarksBegin() + i )->get();
   19.43 +
   19.44 +        // Only keep the bookmarks starting or ending in this node
   19.45 +        if ( pMark->GetMarkStart().nNode == nNd ||
   19.46 +             pMark->GetMarkEnd().nNode == nNd )
   19.47 +        {
   19.48 +            xub_StrLen nBStart = pMark->GetMarkStart().nContent.GetIndex();
   19.49 +            xub_StrLen nBEnd = pMark->GetMarkEnd().nContent.GetIndex();
   19.50 +
   19.51 +            // Keep only the bookmars starting or ending in the snippet
   19.52 +            bool bIsStartOk = ( nBStart >= nStt ) && ( nBStart <= nEnd );
   19.53 +            bool bIsEndOk = ( nBEnd >= nStt ) && ( nBEnd <= nEnd );
   19.54 +
   19.55 +            if ( bIsStartOk || bIsEndOk )
   19.56 +                rArr.push_back( pMark );
   19.57 +        }
   19.58 +    }
   19.59 +    return ( rArr.size() > 0 );
   19.60 +}
   19.61 +
   19.62 +class CompareMarksEnd : public std::binary_function < const IMark *, const IMark *, bool >
   19.63 +{
   19.64 +public:
   19.65 +    inline bool operator() ( const IMark * pOneB, const IMark * pTwoB ) const
   19.66 +    {
   19.67 +        xub_StrLen nOEnd = pOneB->GetMarkEnd().nContent.GetIndex();
   19.68 +        xub_StrLen nTEnd = pTwoB->GetMarkEnd().nContent.GetIndex();
   19.69 +
   19.70 +        return nOEnd < nTEnd;
   19.71 +    }
   19.72 +};
   19.73 +
   19.74 +bool MSWordExportBase::NearestBookmark( xub_StrLen& rNearest )
   19.75 +{
   19.76 +    bool bHasBookmark = false;
   19.77 +
   19.78 +    if ( m_rSortedMarksStart.size( ) > 0 )
   19.79 +    {
   19.80 +        IMark* pMarkStart = m_rSortedMarksStart.front();
   19.81 +        rNearest = pMarkStart->GetMarkStart().nContent.GetIndex();
   19.82 +        bHasBookmark = true;
   19.83 +    }        
   19.84 +
   19.85 +    if ( m_rSortedMarksEnd.size( ) > 0 )
   19.86 +    {
   19.87 +        IMark* pMarkEnd = m_rSortedMarksEnd[0];
   19.88 +        if ( !bHasBookmark )
   19.89 +            rNearest = pMarkEnd->GetMarkEnd().nContent.GetIndex();
   19.90 +        else
   19.91 +            rNearest = std::min( rNearest, pMarkEnd->GetMarkEnd().nContent.GetIndex() );
   19.92 +        bHasBookmark = true;
   19.93 +    }
   19.94 +
   19.95 +    return bHasBookmark;
   19.96 +}
   19.97 +
   19.98 +void MSWordExportBase::GetSortedBookmarks( const SwTxtNode& rNode, xub_StrLen nAktPos, xub_StrLen nLen )
   19.99 +{
  19.100 +    IMarkVector aMarksStart;
  19.101 +    if ( GetBookmarks( rNode, nAktPos, nAktPos + nLen, aMarksStart ) ) 
  19.102 +    {
  19.103 +        IMarkVector aSortedEnd;
  19.104 +        IMarkVector aSortedStart;
  19.105 +        for ( IMarkVector::const_iterator it = aMarksStart.begin(), end = aMarksStart.end();
  19.106 +              it < end; ++it )
  19.107 +        {
  19.108 +            IMark* pMark = (*it);
  19.109 +
  19.110 +            // Remove the positions egals to the current pos
  19.111 +            xub_StrLen nStart = pMark->GetMarkStart().nContent.GetIndex();
  19.112 +            xub_StrLen nEnd = pMark->GetMarkEnd().nContent.GetIndex();
  19.113 +
  19.114 +            if ( nStart > nAktPos )
  19.115 +                aSortedStart.push_back( pMark );
  19.116 +
  19.117 +            if ( nEnd > nAktPos )
  19.118 +                aSortedEnd.push_back( pMark );
  19.119 +        }
  19.120 +
  19.121 +        // Sort the bookmarks by end position
  19.122 +        std::sort( aSortedEnd.begin(), aSortedEnd.end(), CompareMarksEnd() );
  19.123 +    
  19.124 +        m_rSortedMarksStart.swap( aSortedStart );
  19.125 +        m_rSortedMarksEnd.swap( aSortedEnd );
  19.126 +    }
  19.127 +    else
  19.128 +    {
  19.129 +        m_rSortedMarksStart.clear( );
  19.130 +        m_rSortedMarksEnd.clear( );
  19.131 +    }
  19.132  }
  19.133  
  19.134  void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
    20.1 --- a/sw/source/filter/ww8/wrtw8num.cxx	Thu Jul 29 20:08:54 2010 +0200
    20.2 +++ b/sw/source/filter/ww8/wrtw8num.cxx	Thu Jul 29 22:01:25 2010 +0200
    20.3 @@ -721,6 +721,9 @@
    20.4      StarSymbolToMSMultiFont *pConvert = 0;
    20.5      FontFamily eFamily = FAMILY_DECORATIVE;
    20.6  
    20.7 +    if (!bSubstituteBullets)
    20.8 +        return;
    20.9 +
   20.10      if (!pConvert)
   20.11      {
   20.12          pConvert = CreateStarSymbolToMSMultiFont();
    21.1 --- a/sw/source/filter/ww8/wrtw8sty.cxx	Thu Jul 29 20:08:54 2010 +0200
    21.2 +++ b/sw/source/filter/ww8/wrtw8sty.cxx	Thu Jul 29 22:01:25 2010 +0200
    21.3 @@ -79,6 +79,7 @@
    21.4  #include "ww8par.hxx"
    21.5  #include "ww8attributeoutput.hxx"
    21.6  #include "docxattributeoutput.hxx"
    21.7 +#include "rtfattributeoutput.hxx"
    21.8  
    21.9  using namespace sw::util;
   21.10  using namespace nsHdFtFlags;
   21.11 @@ -713,6 +714,17 @@
   21.12  }
   21.13  #endif
   21.14  
   21.15 +void wwFont::WriteRtf( const RtfAttributeOutput* rAttrOutput ) const
   21.16 +{
   21.17 +    rAttrOutput->FontFamilyType( meFamily, *this );
   21.18 +    rAttrOutput->FontPitchType( mePitch );
   21.19 +    rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ) );
   21.20 +    rAttrOutput->StartFont( msFamilyNm );
   21.21 +    if ( mbAlt )
   21.22 +        rAttrOutput->FontAlternateName( msAltNm );
   21.23 +    rAttrOutput->EndFont();
   21.24 +}
   21.25 +
   21.26  bool operator<(const wwFont &r1, const wwFont &r2)
   21.27  {
   21.28      int nRet = memcmp(r1.maWW8_FFN, r2.maWW8_FFN, sizeof(r1.maWW8_FFN));
   21.29 @@ -765,6 +777,22 @@
   21.30          GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
   21.31              pFont->GetFamily(), pFont->GetCharSet(),bWrtWW8));
   21.32      }
   21.33 +
   21.34 +    if (!bLoadAllFonts)
   21.35 +        return;
   21.36 +
   21.37 +    const USHORT aTypes[] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT, 0 };
   21.38 +    for (const USHORT* pId = aTypes; *pId; ++pId)
   21.39 +    {
   21.40 +        USHORT nMaxItem = rPool.GetItemCount( *pId );
   21.41 +        for( USHORT nGet = 0; nGet < nMaxItem; ++nGet )
   21.42 +            if( 0 != (pFont = (const SvxFontItem*)rPool.GetItem(
   21.43 +                            *pId, nGet )) )
   21.44 +            {
   21.45 +                GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
   21.46 +                            pFont->GetFamily(), pFont->GetCharSet(),bWrtWW8));
   21.47 +            }
   21.48 +    }
   21.49  }
   21.50  
   21.51  USHORT wwFontHelper::GetId(const Font& rFont)
   21.52 @@ -839,6 +867,14 @@
   21.53  }
   21.54  #endif
   21.55  
   21.56 +void wwFontHelper::WriteFontTable( const RtfAttributeOutput& rAttrOutput )
   21.57 +{
   21.58 +    ::std::vector<const wwFont *> aFontList( AsVector() );
   21.59 +
   21.60 +    ::std::for_each( aFontList.begin(), aFontList.end(),
   21.61 +        ::std::bind2nd( ::std::mem_fun( &wwFont::WriteRtf ), &rAttrOutput ) );
   21.62 +}
   21.63 +
   21.64  /*  */
   21.65  
   21.66  WW8_WrPlc0::WW8_WrPlc0( ULONG nOffset )
    22.1 --- a/sw/source/filter/ww8/wrtww8.cxx	Thu Jul 29 20:08:54 2010 +0200
    22.2 +++ b/sw/source/filter/ww8/wrtww8.cxx	Thu Jul 29 22:01:25 2010 +0200
    22.3 @@ -3371,7 +3371,7 @@
    22.4      mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0),
    22.5      mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0),
    22.6      pStyles( NULL ),
    22.7 -    bHasHdr(false), bHasFtr(false),
    22.8 +    bHasHdr(false), bHasFtr(false), bSubstituteBullets(true),
    22.9      pDoc( pDocument ),
   22.10      pCurPam( pCurrentPam ),
   22.11      pOrigPam( pOriginalPam )
    23.1 --- a/sw/source/filter/ww8/wrtww8.hxx	Thu Jul 29 20:08:54 2010 +0200
    23.2 +++ b/sw/source/filter/ww8/wrtww8.hxx	Thu Jul 29 22:01:25 2010 +0200
    23.3 @@ -35,6 +35,7 @@
    23.4  #define _SVSTDARR_ULONGS
    23.5  #include <svl/svstdarr.hxx>
    23.6  #endif
    23.7 +#include <svx/editdata.hxx>
    23.8  
    23.9  #include <map>
   23.10  #include <vector>
   23.11 @@ -55,6 +56,7 @@
   23.12  class SwAttrIter;
   23.13  class AttributeOutputBase;
   23.14  class DocxAttributeOutput;
   23.15 +class RtfAttributeOutput;
   23.16  class BitmapPalette;
   23.17  class SwEscherEx;
   23.18  class DateTime;
   23.19 @@ -296,6 +298,7 @@
   23.20  #ifdef DOCX
   23.21      void WriteDocx( const DocxAttributeOutput* rAttrOutput ) const;
   23.22  #endif
   23.23 +    void WriteRtf( const RtfAttributeOutput* rAttrOutput ) const;
   23.24      rtl::OUString GetFamilyName() const { return rtl::OUString( msFamilyNm ); }
   23.25      friend bool operator < (const wwFont &r1, const wwFont &r2);
   23.26  };
   23.27 @@ -311,7 +314,7 @@
   23.28      ::std::vector< const wwFont* > AsVector() const;
   23.29  
   23.30  public:
   23.31 -    wwFontHelper() : mbWrtWW8(false) {}
   23.32 +    wwFontHelper() : mbWrtWW8(false), bLoadAllFonts(false) {}
   23.33      /// rDoc used only to get the initial standard font(s) in use.
   23.34      void InitFontTable(bool bWrtWW8, const SwDoc& rDoc);
   23.35      USHORT GetId(const Font& rFont);
   23.36 @@ -321,6 +324,10 @@
   23.37  #ifdef DOCX
   23.38      void WriteFontTable( const DocxAttributeOutput& rAttrOutput );
   23.39  #endif
   23.40 +    void WriteFontTable( const RtfAttributeOutput& rAttrOutput );
   23.41 +
   23.42 +    /// If true, all fonts are loaded before processing the document.
   23.43 +    BYTE bLoadAllFonts: 1;
   23.44  };
   23.45  
   23.46  class DrawObj
   23.47 @@ -539,6 +546,7 @@
   23.48      BYTE bEndAtTxtEnd : 1;      // true: all END at Textend
   23.49      BYTE bHasHdr : 1;
   23.50      BYTE bHasFtr : 1;
   23.51 +    BYTE bSubstituteBullets : 1; // true: SubstituteBullet() gets called
   23.52  
   23.53      SwDoc *pDoc;
   23.54      SwPaM *pCurPam, *pOrigPam;
   23.55 @@ -546,6 +554,11 @@
   23.56      /// Stack to remember the nesting (see MSWordSaveData for more)
   23.57      ::std::stack< MSWordSaveData > maSaveData;
   23.58  
   23.59 +    /// Used to split the runs according to the bookmarks start and ends
   23.60 +    typedef std::vector< ::sw::mark::IMark* > IMarkVector;
   23.61 +    IMarkVector m_rSortedMarksStart;
   23.62 +    IMarkVector m_rSortedMarksEnd;
   23.63 +
   23.64  public:
   23.65      /// The main function to export the document.
   23.66      void ExportDocument( bool bWriteAll );
   23.67 @@ -785,6 +798,17 @@
   23.68      /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode()
   23.69      void OutputContentNode( const SwCntntNode& );
   23.70      
   23.71 +    /// Find the nearest bookmark from the current position.
   23.72 +    ///
   23.73 +    /// Returns false when there is no bookmark.
   23.74 +    bool NearestBookmark( xub_StrLen& rNearest );
   23.75 +    
   23.76 +    void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, 
   23.77 +                xub_StrLen nLen );
   23.78 +
   23.79 +    bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd,
   23.80 +            IMarkVector& rArr );
   23.81 +
   23.82  public:
   23.83      MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam );
   23.84      virtual ~MSWordExportBase();
   23.85 @@ -1350,6 +1374,47 @@
   23.86      virtual const SfxPoolItem& GetItem( USHORT nWhich ) const = 0;
   23.87  };
   23.88  
   23.89 +class MSWord_SdrAttrIter : public MSWordAttrIter
   23.90 +{
   23.91 +private:
   23.92 +    const EditTextObject* pEditObj;
   23.93 +    const SfxItemPool* pEditPool;
   23.94 +    EECharAttribArray aTxtAtrArr;
   23.95 +    SvPtrarr aChrTxtAtrArr;
   23.96 +    SvUShorts aChrSetArr;
   23.97 +    USHORT nPara;
   23.98 +    xub_StrLen nAktSwPos;
   23.99 +    xub_StrLen nTmpSwPos;                   // for HasItem()
  23.100 +    rtl_TextEncoding eNdChrSet;
  23.101 +    USHORT nScript;
  23.102 +    BYTE mnTyp;
  23.103 +
  23.104 +    xub_StrLen SearchNext( xub_StrLen nStartPos );
  23.105 +    void SetCharSet(const EECharAttrib& rTxtAttr, bool bStart);
  23.106 +
  23.107 +    //No copying
  23.108 +    MSWord_SdrAttrIter(const MSWord_SdrAttrIter&);
  23.109 +    MSWord_SdrAttrIter& operator=(const MSWord_SdrAttrIter&);
  23.110 +public:
  23.111 +    MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj,
  23.112 +        BYTE nType );
  23.113 +    void NextPara( USHORT nPar );
  23.114 +    void OutParaAttr(bool bCharAttr);
  23.115 +    void OutEEField(const SfxPoolItem& rHt);
  23.116 +
  23.117 +    bool IsTxtAttr(xub_StrLen nSwPos);
  23.118 +
  23.119 +    void NextPos() { nAktSwPos = SearchNext( nAktSwPos + 1 ); }
  23.120 +
  23.121 +    void OutAttr( xub_StrLen nSwPos );
  23.122 +    virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const;
  23.123 +    virtual const SfxPoolItem& GetItem( USHORT nWhich ) const;
  23.124 +    bool OutAttrWithRange(xub_StrLen nPos);
  23.125 +    xub_StrLen WhereNext() const                { return nAktSwPos; }
  23.126 +    rtl_TextEncoding GetNextCharSet() const;
  23.127 +    rtl_TextEncoding GetNodeCharSet() const     { return eNdChrSet; }
  23.128 +};
  23.129 +
  23.130  /// Class to collect and output the styles table.
  23.131  class MSWordStyles
  23.132  {
    24.1 --- a/sw/source/filter/ww8/ww8atr.cxx	Thu Jul 29 20:08:54 2010 +0200
    24.2 +++ b/sw/source/filter/ww8/ww8atr.cxx	Thu Jul 29 22:01:25 2010 +0200
    24.3 @@ -3340,7 +3340,7 @@
    24.4          m_rWW8Export.pO->Insert( (BYTE)0x02, m_rWW8Export.pO->Count() );
    24.5  
    24.6          sal_Unicode cStart = rTwoLines.GetStartBracket();
    24.7 -        sal_Unicode cEnd = rTwoLines.GetStartBracket();
    24.8 +        sal_Unicode cEnd = rTwoLines.GetEndBracket();
    24.9  
   24.10          /*
   24.11          As per usual we have problems. We can have seperate left and right brackets