LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - wrtw8sty.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 1291 0.0 %
Date: 2014-04-14 Functions: 0 106 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <algorithm>
      21             : #include <functional>
      22             : 
      23             : #include <boost/scoped_array.hpp>
      24             : #include <boost/unordered_set.hpp>
      25             : 
      26             : #include <com/sun/star/i18n/ScriptType.hpp>
      27             : #include <rtl/tencinfo.h>
      28             : #include <hintids.hxx>
      29             : #include <editeng/boxitem.hxx>
      30             : #include <editeng/fontitem.hxx>
      31             : #include <svx/svdobj.hxx>
      32             : #include <svx/svdotext.hxx>
      33             : #include <svx/fmglob.hxx>
      34             : #include <editeng/frmdiritem.hxx>
      35             : #include <editeng/lrspitem.hxx>
      36             : #include <editeng/ulspitem.hxx>
      37             : #include <doc.hxx>
      38             : #include <wrtww8.hxx>
      39             : #include <docary.hxx>
      40             : #include <poolfmt.hxx>
      41             : #include <fmtpdsc.hxx>
      42             : #include <pagedesc.hxx>
      43             : #include <ndtxt.hxx>
      44             : #include <ftninfo.hxx>
      45             : #include <fmthdft.hxx>
      46             : #include <section.hxx>
      47             : #include <fmtcntnt.hxx>
      48             : #include <fmtftn.hxx>
      49             : #include <ndindex.hxx>
      50             : #include <txtftn.hxx>
      51             : #include <charfmt.hxx>
      52             : #include <docufld.hxx>
      53             : #include <dcontact.hxx>
      54             : #include <fmtcnct.hxx>
      55             : #include <ftnidx.hxx>
      56             : #include <fmtclds.hxx>
      57             : #include <lineinfo.hxx>
      58             : #include <fmtline.hxx>
      59             : #include <swtable.hxx>
      60             : #include <msfilter.hxx>
      61             : #include <swmodule.hxx>
      62             : 
      63             : #include <filter/msfilter/sprmids.hxx>
      64             : 
      65             : #include "writerhelper.hxx"
      66             : #include "writerwordglue.hxx"
      67             : #include "../inc/wwstyles.hxx"
      68             : #include "ww8par.hxx"
      69             : #include "ww8attributeoutput.hxx"
      70             : #include "docxattributeoutput.hxx"
      71             : #include "rtfattributeoutput.hxx"
      72             : 
      73             : using namespace css;
      74             : using namespace sw::util;
      75             : using namespace nsHdFtFlags;
      76             : 
      77             : /// For the output of sections.
      78           0 : struct WW8_PdAttrDesc
      79             : {
      80             :     ::boost::scoped_array<sal_uInt8> m_pData;
      81             :     sal_uInt16 m_nLen;
      82             :     WW8_FC m_nSepxFcPos;
      83           0 :     WW8_PdAttrDesc() : m_nLen(0), m_nSepxFcPos(0xffffffff) /*default: none*/
      84           0 :         { }
      85             : };
      86             : 
      87             : struct WW8_SED
      88             : {
      89             :     SVBT16 aBits1;      // orientation change + internal, Default: 6
      90             :     SVBT32 fcSepx;      //  FC  file offset to beginning of SEPX for section.
      91             :                         //  0xFFFFFFFF for no Sprms
      92             :     SVBT16 fnMpr;       //  used internally by Windows Word, Default: 0
      93             :     SVBT32 fcMpr;       //  FC, points to offset in FC space for MacWord
      94             :                         // Default: 0xffffffff ( nothing )
      95             :                         //  cbSED is 12 (decimal)), C (hex).
      96             : };
      97             : 
      98             : // class WW8_WrPlc0 is only used for header and footer positioning
      99             : // ie there is no content support structure
     100           0 : class WW8_WrPlc0
     101             : {
     102             : private:
     103             :     std::vector<sal_uLong> aPos;      // PTRARR of CPs / FCs
     104             :     sal_uLong nOfs;
     105             : 
     106             :     //No copying
     107             :     WW8_WrPlc0(const WW8_WrPlc0&);
     108             :     WW8_WrPlc0 &operator=(const WW8_WrPlc0&);
     109             : public:
     110             :     WW8_WrPlc0( sal_uLong nOffset );
     111           0 :     sal_uInt16 Count() const                { return aPos.size(); }
     112             :     void Append( sal_uLong nStartCpOrFc );
     113             :     void Write( SvStream& rStrm );
     114             : };
     115             : 
     116             : //  Styles
     117             : 
     118             : #define WW8_RESERVED_SLOTS 15
     119             : 
     120             : // GetId( SwCharFmt ) for use in text -> zero is not allowed,
     121             : // use "Default Char Style" instead
     122           0 : sal_uInt16 MSWordExportBase::GetId( const SwCharFmt& rFmt ) const
     123             : {
     124           0 :     sal_uInt16 nRet = pStyles->GetSlot( rFmt );
     125           0 :     return ( nRet != 0x0fff ) ? nRet : 10;      // Default Char Style
     126             : }
     127             : 
     128             : // GetId( SwTxtFmtColl ) for use in TextNodes -> zero is not allowed,
     129             : // "Standard" instead
     130           0 : sal_uInt16 MSWordExportBase::GetId( const SwTxtFmtColl& rColl ) const
     131             : {
     132           0 :     sal_uInt16 nRet = pStyles->GetSlot( rColl );
     133           0 :     return ( nRet != 0xfff ) ? nRet : 0;        // Default TxtFmtColl
     134             : }
     135             : 
     136             : //typedef pFmtT
     137           0 : MSWordStyles::MSWordStyles( MSWordExportBase& rExport, bool bListStyles )
     138             :     : m_rExport( rExport ),
     139           0 :     m_bListStyles(bListStyles)
     140             : {
     141             :     // if exist any Foot-/End-Notes then get from the EndNoteInfo struct
     142             :     // the CharFormats. They will create it!
     143           0 :     if ( !m_rExport.pDoc->GetFtnIdxs().empty() )
     144             :     {
     145           0 :         m_rExport.pDoc->GetEndNoteInfo().GetAnchorCharFmt( *m_rExport.pDoc );
     146           0 :         m_rExport.pDoc->GetEndNoteInfo().GetCharFmt( *m_rExport.pDoc );
     147           0 :         m_rExport.pDoc->GetFtnInfo().GetAnchorCharFmt( *m_rExport.pDoc );
     148           0 :         m_rExport.pDoc->GetFtnInfo().GetCharFmt( *m_rExport.pDoc );
     149             :     }
     150           0 :     sal_uInt16 nAlloc = WW8_RESERVED_SLOTS + m_rExport.pDoc->GetCharFmts()->size() - 1 +
     151           0 :                                          m_rExport.pDoc->GetTxtFmtColls()->size() - 1 +
     152           0 :                                          (bListStyles ? m_rExport.pDoc->GetNumRuleTbl().size() - 1 : 0);
     153             : 
     154             :     // somewhat generous ( free for up to 15 )
     155           0 :     pFmtA = new SwFmt*[ nAlloc ];
     156           0 :     memset( pFmtA, 0, nAlloc * sizeof( SwFmt* ) );
     157             : 
     158           0 :     BuildStylesTable();
     159           0 :     BuildStyleIds();
     160           0 : }
     161             : 
     162           0 : MSWordStyles::~MSWordStyles()
     163             : {
     164           0 :     delete[] pFmtA;
     165           0 : }
     166             : 
     167             : // Sty_SetWWSlot() dependencies for the styles -> zero is allowed
     168           0 : sal_uInt16 MSWordStyles::GetSlot( const SwFmt& rFmt ) const
     169             : {
     170             :     sal_uInt16 n;
     171           0 :     for ( n = 0; n < nUsedSlots; n++ )
     172           0 :         if ( pFmtA[n] == &rFmt )
     173           0 :             return n;
     174           0 :     return 0xfff;                   // 0xfff: WW: zero
     175             : }
     176             : 
     177           0 : sal_uInt16 MSWordStyles::BuildGetSlot( const SwFmt& rFmt )
     178             : {
     179             :     sal_uInt16 nRet;
     180           0 :     switch ( nRet = rFmt.GetPoolFmtId() )
     181             :     {
     182             :         case RES_POOLCOLL_STANDARD:
     183           0 :             nRet = 0;
     184           0 :             break;
     185             : 
     186             :         case RES_POOLCOLL_HEADLINE1:
     187             :         case RES_POOLCOLL_HEADLINE2:
     188             :         case RES_POOLCOLL_HEADLINE3:
     189             :         case RES_POOLCOLL_HEADLINE4:
     190             :         case RES_POOLCOLL_HEADLINE5:
     191             :         case RES_POOLCOLL_HEADLINE6:
     192             :         case RES_POOLCOLL_HEADLINE7:
     193             :         case RES_POOLCOLL_HEADLINE8:
     194             :         case RES_POOLCOLL_HEADLINE9:
     195           0 :             nRet -= RES_POOLCOLL_HEADLINE1-1;
     196           0 :             break;
     197             : 
     198             :         default:
     199           0 :             nRet = nUsedSlots++;
     200           0 :             break;
     201             :     }
     202           0 :     return nRet;
     203             : }
     204             : 
     205           0 : sal_uInt16 MSWordStyles::BuildGetSlot(const SwNumRule&)
     206             : {
     207           0 :     return nUsedSlots++;
     208             : }
     209             : 
     210           0 : sal_uInt16 MSWordStyles::GetWWId( const SwFmt& rFmt ) const
     211             : {
     212           0 :     sal_uInt16 nRet = ww::stiUser;    // User-Style als default
     213           0 :     sal_uInt16 nPoolId = rFmt.GetPoolFmtId();
     214           0 :     if( nPoolId == RES_POOLCOLL_STANDARD )
     215           0 :         nRet = 0;
     216           0 :     else if( nPoolId >= RES_POOLCOLL_HEADLINE1 &&
     217             :              nPoolId <= RES_POOLCOLL_HEADLINE9 )
     218           0 :         nRet = static_cast< sal_uInt16 >(nPoolId + 1 - RES_POOLCOLL_HEADLINE1);
     219           0 :     else if( nPoolId >= RES_POOLCOLL_TOX_IDX1 &&
     220             :              nPoolId <= RES_POOLCOLL_TOX_IDX3 )
     221           0 :         nRet = static_cast< sal_uInt16 >(nPoolId + 10 - RES_POOLCOLL_TOX_IDX1);
     222           0 :     else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT1 &&
     223             :              nPoolId <= RES_POOLCOLL_TOX_CNTNT5 )
     224           0 :         nRet = static_cast< sal_uInt16 >(nPoolId + 19 - RES_POOLCOLL_TOX_CNTNT1);
     225           0 :     else if( nPoolId >= RES_POOLCOLL_TOX_CNTNT6 &&
     226             :              nPoolId <= RES_POOLCOLL_TOX_CNTNT9 )
     227           0 :         nRet = static_cast< sal_uInt16 >(nPoolId + 24 - RES_POOLCOLL_TOX_CNTNT6);
     228             :     else
     229           0 :         switch( nPoolId )
     230             :         {
     231           0 :         case RES_POOLCOLL_FOOTNOTE:         nRet = 29;  break;
     232           0 :         case RES_POOLCOLL_MARGINAL:         nRet = 30;  break;
     233           0 :         case RES_POOLCOLL_HEADER:           nRet = 31;  break;
     234           0 :         case RES_POOLCOLL_FOOTER:           nRet = 32;  break;
     235           0 :         case RES_POOLCOLL_TOX_IDXH:         nRet = 33;  break;
     236           0 :         case RES_POOLCOLL_LABEL:            nRet = 34;  break;
     237           0 :         case RES_POOLCOLL_LABEL_DRAWING:    nRet = 35;  break;
     238           0 :         case RES_POOLCOLL_JAKETADRESS:      nRet = 36;  break;
     239           0 :         case RES_POOLCOLL_SENDADRESS:       nRet = 37;  break;
     240           0 :         case RES_POOLCOLL_ENDNOTE:          nRet = 43;  break;
     241           0 :         case RES_POOLCOLL_TOX_AUTHORITIESH: nRet = 44;  break;
     242           0 :         case RES_POOLCOLL_TOX_CNTNTH:       nRet = 46;  break;
     243           0 :         case RES_POOLCOLL_BUL_LEVEL1:       nRet = 48;  break;
     244           0 :         case RES_POOLCOLL_LISTS_BEGIN:      nRet = 47;  break;
     245           0 :         case RES_POOLCOLL_NUM_LEVEL1:       nRet = 49;  break;
     246           0 :         case RES_POOLCOLL_BUL_LEVEL2:       nRet = 54;  break;
     247           0 :         case RES_POOLCOLL_BUL_LEVEL3:       nRet = 55;  break;
     248           0 :         case RES_POOLCOLL_BUL_LEVEL4:       nRet = 56;  break;
     249           0 :         case RES_POOLCOLL_BUL_LEVEL5:       nRet = 57;  break;
     250           0 :         case RES_POOLCOLL_NUM_LEVEL2:       nRet = 58;  break;
     251           0 :         case RES_POOLCOLL_NUM_LEVEL3:       nRet = 59;  break;
     252           0 :         case RES_POOLCOLL_NUM_LEVEL4:       nRet = 60;  break;
     253           0 :         case RES_POOLCOLL_NUM_LEVEL5:       nRet = 61;  break;
     254           0 :         case RES_POOLCOLL_DOC_TITEL:        nRet = 62;  break;
     255           0 :         case RES_POOLCOLL_SIGNATURE:        nRet = 64;  break;
     256           0 :         case RES_POOLCOLL_TEXT:             nRet = 66;  break;
     257           0 :         case RES_POOLCOLL_TEXT_MOVE:        nRet = 67;  break;
     258           0 :         case RES_POOLCOLL_BUL_NONUM1:       nRet = 68;  break;
     259           0 :         case RES_POOLCOLL_BUL_NONUM2:       nRet = 69;  break;
     260           0 :         case RES_POOLCOLL_BUL_NONUM3:       nRet = 70;  break;
     261           0 :         case RES_POOLCOLL_BUL_NONUM4:       nRet = 71;  break;
     262           0 :         case RES_POOLCOLL_BUL_NONUM5:       nRet = 72;  break;
     263           0 :         case RES_POOLCOLL_DOC_SUBTITEL:     nRet = 74;  break;
     264           0 :         case RES_POOLCOLL_GREETING:         nRet = 75;  break;
     265           0 :         case RES_POOLCOLL_TEXT_IDENT:       nRet = 77;  break;
     266             : 
     267           0 :         case RES_POOLCHR_FOOTNOTE_ANCHOR:   nRet = 38;  break;
     268           0 :         case RES_POOLCHR_ENDNOTE_ANCHOR:    nRet = 42;  break;
     269           0 :         case RES_POOLCHR_INET_NORMAL:       nRet = 85;  break;
     270           0 :         case RES_POOLCHR_INET_VISIT:        nRet = 86;  break;
     271           0 :         case RES_POOLCHR_HTML_STRONG:       nRet = 87;  break;
     272           0 :         case RES_POOLCHR_HTML_EMPHASIS:     nRet = 88;  break;
     273           0 :         case RES_POOLCHR_LINENUM:           nRet = 40;  break;
     274           0 :         case RES_POOLCHR_PAGENO:            nRet = 41;  break;
     275             :         }
     276           0 :     return nRet;
     277             : }
     278             : 
     279           0 : void MSWordStyles::BuildStylesTable()
     280             : {
     281           0 :     nUsedSlots = WW8_RESERVED_SLOTS;    // soviele sind reserviert fuer
     282             :                                         // Standard und HeadingX u.a.
     283           0 :     const SwCharFmts& rArr = *m_rExport.pDoc->GetCharFmts();       // first CharFmt
     284             :     // das Default-ZeichenStyle ( 0 ) wird nicht mit ausgegeben !
     285           0 :     for( sal_uInt16 n = 1; n < rArr.size(); n++ )
     286             :     {
     287           0 :         SwCharFmt* pFmt = rArr[n];
     288           0 :         pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt;
     289             :     }
     290             : 
     291           0 :     const SwTxtFmtColls& rArr2 = *m_rExport.pDoc->GetTxtFmtColls();   // then TxtFmtColls
     292             :     // das Default-TextStyle ( 0 ) wird nicht mit ausgegeben !
     293           0 :     for( sal_uInt16 n = 1; n < rArr2.size(); n++ )
     294             :     {
     295           0 :         SwTxtFmtColl* pFmt = rArr2[n];
     296           0 :         pFmtA[ BuildGetSlot( *pFmt ) ] = pFmt;
     297             :     }
     298             : 
     299           0 :     if (!m_bListStyles)
     300           0 :         return;
     301             : 
     302           0 :     const SwNumRuleTbl& rNumRuleTbl = m_rExport.pDoc->GetNumRuleTbl();
     303           0 :     for (size_t i = 0; i < rNumRuleTbl.size(); ++i)
     304             :     {
     305           0 :         const SwNumRule* pNumRule = rNumRuleTbl[i];
     306           0 :         if (pNumRule->IsAutoRule() || pNumRule->GetName().startsWith("WWNum"))
     307           0 :             continue;
     308           0 :         sal_uInt16 nSlot = BuildGetSlot(*pNumRule);
     309           0 :         m_aNumRules[nSlot] = pNumRule;
     310             :     }
     311             : }
     312             : 
     313           0 : void MSWordStyles::BuildStyleIds()
     314             : {
     315           0 :     boost::unordered_set<OString, OStringHash> aUsed;
     316             : 
     317           0 :     m_aStyleIds.push_back("Normal");
     318           0 :     aUsed.insert("normal");
     319             : 
     320           0 :     for (sal_uInt16 n = 1; n < nUsedSlots; ++n)
     321             :     {
     322           0 :         const OUString aName(pFmtA[n]? pFmtA[n]->GetName(): (m_aNumRules.find(n) != m_aNumRules.end() ? m_aNumRules[n]->GetName() : OUString()));
     323             : 
     324           0 :         OStringBuffer aStyleIdBuf(aName.getLength());
     325           0 :         for (int i = 0; i < aName.getLength(); ++i)
     326             :         {
     327           0 :             sal_Unicode nChar = aName[i];
     328           0 :             if (('0' <= nChar && nChar <= '9') ||
     329           0 :                 ('a' <= nChar && nChar <= 'z') ||
     330           0 :                 ('A' <= nChar && nChar <= 'Z'))
     331             :             {
     332             :                 // first letter should be uppercase
     333           0 :                 if (aStyleIdBuf.isEmpty() && 'a' <= nChar && nChar <= 'z')
     334           0 :                     aStyleIdBuf.append(char(nChar - ('a' - 'A')));
     335             :                 else
     336           0 :                     aStyleIdBuf.append(char(nChar));
     337             :             }
     338             :         }
     339             : 
     340           0 :         OString aStyleId(aStyleIdBuf.makeStringAndClear());
     341           0 :         if (aStyleId.isEmpty())
     342           0 :             aStyleId = "Style";
     343             : 
     344           0 :         OString aLower(aStyleId.toAsciiLowerCase());
     345             : 
     346             :         // check for uniqueness & construct something unique if we have to
     347           0 :         if (aUsed.find(aLower) == aUsed.end())
     348             :         {
     349           0 :             aUsed.insert(aLower);
     350           0 :             m_aStyleIds.push_back(aStyleId);
     351             :         }
     352             :         else
     353             :         {
     354           0 :             int nFree = 1;
     355           0 :             while (aUsed.find(aLower + OString::number(nFree)) != aUsed.end())
     356           0 :                 ++nFree;
     357             : 
     358           0 :             aUsed.insert(aLower + OString::number(nFree));
     359           0 :             m_aStyleIds.push_back(aStyleId + OString::number(nFree));
     360             :         }
     361           0 :     }
     362           0 : }
     363             : 
     364           0 : OString MSWordStyles::GetStyleId(sal_uInt16 nId) const
     365             : {
     366           0 :     return m_aStyleIds[nId];
     367             : }
     368             : 
     369             : /// For WW8 only - extend pO so that the size of pTableStrm is even.
     370           0 : static void impl_SkipOdd( ww::bytes* pO, sal_Size nTableStrmTell )
     371             : {
     372           0 :     if ( ( nTableStrmTell + pO->size() ) & 1 )     // Start auf gerader
     373           0 :         pO->push_back( (sal_uInt8)0 );         // Address
     374           0 : }
     375             : 
     376           0 : void WW8AttributeOutput::EndStyle()
     377             : {
     378           0 :     impl_SkipOdd( m_rWW8Export.pO, m_rWW8Export.pTableStrm->Tell() );
     379             : 
     380           0 :     short nLen = m_rWW8Export.pO->size() - 2;            // length of the style
     381           0 :     sal_uInt8* p = &m_rWW8Export.pO->front() + nPOPosStdLen1;
     382           0 :     ShortToSVBT16( nLen, p );               // nachtragen
     383           0 :     p = &m_rWW8Export.pO->front() + nPOPosStdLen2;
     384           0 :     ShortToSVBT16( nLen, p );               // dito
     385             : 
     386           0 :     m_rWW8Export.pTableStrm->Write( m_rWW8Export.pO->data(), m_rWW8Export.pO->size() );      // write it into the file
     387           0 :     m_rWW8Export.pO->clear();
     388           0 : }
     389             : 
     390           0 : void WW8AttributeOutput::StartStyle( const OUString& rName, StyleType eType, sal_uInt16 nWwBase,
     391             :     sal_uInt16 nWwNext, sal_uInt16 nWwId, sal_uInt16 /*nId*/, bool bAutoUpdate )
     392             : {
     393             :     sal_uInt8 aWW8_STD[ sizeof( WW8_STD ) ];
     394           0 :     sal_uInt8* pData = aWW8_STD;
     395           0 :     memset( &aWW8_STD, 0, sizeof( WW8_STD ) );
     396             : 
     397           0 :     sal_uInt16 nBit16 = 0x1000;         // fInvalHeight
     398           0 :     nBit16 |= (ww::stiNil & nWwId);
     399           0 :     Set_UInt16( pData, nBit16 );
     400             : 
     401           0 :     nBit16 = nWwBase << 4;          // istdBase
     402           0 :     nBit16 |= (eType == STYLE_TYPE_PARA ? 1 : 2);      // sgc
     403           0 :     Set_UInt16( pData, nBit16 );
     404             : 
     405           0 :     nBit16 = nWwNext << 4;          // istdNext
     406           0 :     nBit16 |= (eType == STYLE_TYPE_PARA ? 2 : 1);      // cupx
     407           0 :     Set_UInt16( pData, nBit16 );
     408             : 
     409           0 :     pData += sizeof( sal_uInt16 );      // bchUpe
     410             : 
     411           0 :     if( m_rWW8Export.bWrtWW8 )
     412             :     {
     413           0 :         nBit16 = bAutoUpdate ? 1 : 0;  // fAutoRedef : 1
     414           0 :         Set_UInt16( pData, nBit16 );
     415             :         //-------- jetzt neu:
     416             :         // ab Ver8 gibts zwei Felder mehr:
     417             :         //sal_uInt16    fHidden : 1;       /* hidden from UI? */
     418             :         //sal_uInt16    : 14;              /* unused bits */
     419             :     }
     420             : 
     421           0 :     sal_uInt16 nLen = static_cast< sal_uInt16 >( ( pData - aWW8_STD ) + 1 +
     422           0 :                 ((m_rWW8Export.bWrtWW8 ? 2 : 1 ) * (rName.getLength() + 1)) );  // temporary
     423             : 
     424           0 :     nPOPosStdLen1 = m_rWW8Export.pO->size();        // Adr1 zum nachtragen der Laenge
     425             : 
     426           0 :     SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nLen );
     427           0 :     m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aWW8_STD, pData );
     428             : 
     429           0 :     nPOPosStdLen2 = nPOPosStdLen1 + 8;  // Adr2 zum nachtragen von "end of upx"
     430             : 
     431             :     // write names
     432           0 :     if( m_rWW8Export.bWrtWW8 )
     433             :     {
     434           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, rName.getLength() ); // length
     435           0 :         SwWW8Writer::InsAsString16( *m_rWW8Export.pO, rName );
     436             :     }
     437             :     else
     438             :     {
     439           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)rName.getLength() );       // length
     440           0 :         SwWW8Writer::InsAsString8( *m_rWW8Export.pO, rName, RTL_TEXTENCODING_MS_1252 );
     441             :     }
     442           0 :     m_rWW8Export.pO->push_back( (sal_uInt8)0 );             // Trotz P-String 0 am Ende!
     443           0 : }
     444             : 
     445           0 : void MSWordStyles::SetStyleDefaults( const SwFmt& rFmt, bool bPap )
     446             : {
     447           0 :     const SwModify* pOldMod = m_rExport.pOutFmtNode;
     448           0 :     m_rExport.pOutFmtNode = &rFmt;
     449             :     bool aFlags[ static_cast< sal_uInt16 >(RES_FRMATR_END) - RES_CHRATR_BEGIN ];
     450             :     sal_uInt16 nStt, nEnd, n;
     451           0 :     if( bPap )
     452           0 :        nStt = RES_PARATR_BEGIN, nEnd = RES_FRMATR_END;
     453             :     else
     454           0 :        nStt = RES_CHRATR_BEGIN, nEnd = RES_TXTATR_END;
     455             : 
     456             :     // dynamic defaults
     457           0 :     const SfxItemPool& rPool = *rFmt.GetAttrSet().GetPool();
     458           0 :     for( n = nStt; n < nEnd; ++n )
     459           0 :         aFlags[ n - RES_CHRATR_BEGIN ] = 0 != rPool.GetPoolDefaultItem( n );
     460             : 
     461             :     // static defaults, that differs between WinWord and SO
     462           0 :     if( bPap )
     463             :     {
     464           0 :         aFlags[ static_cast< sal_uInt16 >(RES_PARATR_WIDOWS) - RES_CHRATR_BEGIN ] = true;
     465           0 :         aFlags[ static_cast< sal_uInt16 >(RES_PARATR_HYPHENZONE) - RES_CHRATR_BEGIN ] = true;
     466             :     }
     467             :     else
     468             :     {
     469           0 :         aFlags[ RES_CHRATR_FONTSIZE - RES_CHRATR_BEGIN ] = true;
     470           0 :         aFlags[ RES_CHRATR_LANGUAGE - RES_CHRATR_BEGIN ] = true;
     471             :     }
     472             : 
     473           0 :     const SfxItemSet* pOldI = m_rExport.GetCurItemSet();
     474           0 :     m_rExport.SetCurItemSet( &rFmt.GetAttrSet() );
     475             : 
     476           0 :     const bool* pFlags = aFlags + ( nStt - RES_CHRATR_BEGIN );
     477           0 :     for ( n = nStt; n < nEnd; ++n, ++pFlags )
     478             :     {
     479           0 :         if ( *pFlags && !m_rExport.ignoreAttributeForStyles( n )
     480           0 :             && SFX_ITEM_SET != rFmt.GetItemState(n, false))
     481             :         {
     482             :             //If we are a character property then see if it is one of the
     483             :             //western/asian ones that must be collapsed together for export to
     484             :             //word. If so default to the western variant.
     485           0 :             if ( bPap || m_rExport.CollapseScriptsforWordOk(
     486           0 :                 i18n::ScriptType::LATIN, n) )
     487             :             {
     488           0 :                 m_rExport.AttrOutput().OutputItem( rFmt.GetFmtAttr( n, true ) );
     489             :             }
     490             :         }
     491             :     }
     492             : 
     493           0 :     m_rExport.SetCurItemSet( pOldI );
     494           0 :     m_rExport.pOutFmtNode = pOldMod;
     495           0 : }
     496             : 
     497           0 : void WW8AttributeOutput::StartStyleProperties( bool bParProp, sal_uInt16 nStyle )
     498             : {
     499           0 :     impl_SkipOdd( m_rWW8Export.pO, m_rWW8Export.pTableStrm->Tell() );
     500             : 
     501           0 :     sal_uInt16 nLen = ( bParProp ) ? 2 : 0;             // default length
     502           0 :     m_nStyleLenPos = m_rWW8Export.pO->size();               // Laenge zum Nachtragen
     503             :                                     // Keinen Pointer merken, da sich bei
     504             :                                     // _grow der Pointer aendert !
     505             : 
     506           0 :     SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nLen );        // Style-Len
     507             : 
     508           0 :     m_nStyleStartSize = m_rWW8Export.pO->size();
     509             : 
     510           0 :     if ( bParProp )
     511           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nStyle );     // Style-Nummer
     512           0 : }
     513             : 
     514           0 : void MSWordStyles::WriteProperties( const SwFmt* pFmt, bool bParProp, sal_uInt16 nPos,
     515             :     bool bInsDefCharSiz )
     516             : {
     517           0 :     m_rExport.AttrOutput().StartStyleProperties( bParProp, nPos );
     518             : 
     519             :     OSL_ENSURE( m_rExport.pCurrentStyle == NULL, "Current style not NULL" ); // set current style before calling out
     520           0 :     m_rExport.pCurrentStyle = pFmt;
     521             : 
     522           0 :     m_rExport.OutputFormat( *pFmt, bParProp, !bParProp );
     523             : 
     524             :     OSL_ENSURE( m_rExport.pCurrentStyle == pFmt, "current style was changed" );
     525             :     // reset current style...
     526           0 :     m_rExport.pCurrentStyle = NULL;
     527             : 
     528           0 :     if ( bInsDefCharSiz  )                   // not derived from other Style
     529           0 :         SetStyleDefaults( *pFmt, bParProp );
     530             : 
     531           0 :     m_rExport.AttrOutput().EndStyleProperties( bParProp );
     532           0 : }
     533             : 
     534           0 : void WW8AttributeOutput::EndStyleProperties( bool /*bParProp*/ )
     535             : {
     536           0 :     sal_uInt16 nLen = m_rWW8Export.pO->size() - m_nStyleStartSize;
     537           0 :     sal_uInt8* pUpxLen = &m_rWW8Export.pO->front() + m_nStyleLenPos; // Laenge zum Nachtragen
     538           0 :     ShortToSVBT16( nLen, pUpxLen );                 // add default length
     539           0 : }
     540             : 
     541           0 : void MSWordStyles::GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase, sal_uInt16& nNext )
     542             : {
     543           0 :     bFmtColl = pFmt->Which() == RES_TXTFMTCOLL || pFmt->Which() == RES_CONDTXTFMTCOLL;
     544             : 
     545             :     // Default: none
     546           0 :     nBase = 0xfff;
     547             : 
     548             :     // Derived from?
     549           0 :     if ( !pFmt->IsDefault() )
     550           0 :         nBase = GetSlot( *pFmt->DerivedFrom() );
     551             : 
     552             :     SwFmt* pNext;
     553           0 :     if ( bFmtColl )
     554           0 :         pNext = &((SwTxtFmtColl*)pFmt)->GetNextTxtFmtColl();
     555             :     else
     556           0 :         pNext = pFmt; // CharFmt: next CharFmt == self
     557             : 
     558           0 :     nNext = GetSlot( *pNext );
     559           0 : }
     560             : 
     561           0 : void WW8AttributeOutput::DefaultStyle( sal_uInt16 nStyle )
     562             : {
     563           0 :     if ( nStyle == 10 )           // Default Char-Style ( only WW )
     564             :     {
     565           0 :         if ( m_rWW8Export.bWrtWW8 )
     566             :         {
     567           0 :             sal_uInt16 n = 0;
     568           0 :             m_rWW8Export.pTableStrm->Write( &n , 2 );   // empty Style
     569             :         }
     570             :         else
     571             :         {
     572             :             static sal_uInt8 aDefCharSty[] = {
     573             :                 0x26, 0x00,
     574             :                 0x41, 0x40, 0xF2, 0xFF, 0xA1, 0x00, 0x26, 0x00,
     575             :                 0x19, 0x41, 0x62, 0x73, 0x61, 0x74, 0x7A, 0x2D,
     576             :                 0x53, 0x74, 0x61, 0x6E, 0x64, 0x61, 0x72, 0x64,
     577             :                 0x73, 0x63, 0x68, 0x72, 0x69, 0x66, 0x74, 0x61,
     578             :                 0x72, 0x74, 0x00, 0x00, 0x00, 0x00 };
     579           0 :             m_rWW8Export.pTableStrm->Write( &aDefCharSty, sizeof( aDefCharSty ) );
     580             :         }
     581             :     }
     582             :     else
     583             :     {
     584           0 :         sal_uInt16 n = 0;
     585           0 :         m_rWW8Export.pTableStrm->Write( &n , 2 );   // empty Style
     586             :     }
     587           0 : }
     588             : 
     589           0 : void MSWordStyles::OutputStyle(const SwNumRule* pNumRule, sal_uInt16 nPos)
     590             : {
     591           0 :     m_rExport.AttrOutput().StartStyle( pNumRule->GetName(), STYLE_TYPE_LIST,
     592             :             /*nBase =*/ 0, /*nWwNext =*/ 0, /*nWWId =*/ 0, nPos,
     593           0 :             /*bAutoUpdateFmt =*/ false );
     594             : 
     595           0 :     m_rExport.AttrOutput().EndStyle();
     596           0 : }
     597             : 
     598             : // OutputStyle applies for TxtFmtColls and CharFmts
     599           0 : void MSWordStyles::OutputStyle( SwFmt* pFmt, sal_uInt16 nPos )
     600             : {
     601           0 :     if ( !pFmt )
     602           0 :         m_rExport.AttrOutput().DefaultStyle( nPos );
     603             :     else
     604             :     {
     605             :         bool bFmtColl;
     606             :         sal_uInt16 nBase, nWwNext;
     607             : 
     608           0 :         GetStyleData( pFmt, bFmtColl, nBase, nWwNext );
     609             : 
     610           0 :         OUString aName = pFmt->GetName();
     611             :         // We want to map LO's default style to Word's "Normal" style.
     612             :         // Word looks for this specific style name when reading docx files.
     613             :         // (It must be the English word regardless of language settings)
     614           0 :         if ( nPos == 0 )
     615             :         {
     616             :             assert( pFmt->GetPoolFmtId() == RES_POOLCOLL_STANDARD );
     617           0 :             aName = "Normal";
     618             :         }
     619           0 :         else if (aName.equalsIgnoreAsciiCase("Normal"))
     620             :         {
     621             :             // If LO has a style named "Normal"(!) rename it to something unique
     622           0 :             const OUString aBaseName = "LO-" + aName;
     623           0 :             aName = aBaseName;
     624             :             // Check if we still have a clash, in which case we add a suffix
     625           0 :             for ( int nSuffix = 0; ; ++nSuffix ) {
     626           0 :                 bool clash=false;
     627           0 :                 for ( sal_uInt16 n = 1; n < nUsedSlots; ++n )
     628           0 :                     if ( pFmtA[n] &&
     629           0 :                          pFmtA[n]->GetName().equalsIgnoreAsciiCase(aName) )
     630             :                     {
     631           0 :                         clash = true;
     632           0 :                         break;
     633             :                     }
     634           0 :                 if (!clash)
     635           0 :                     break;
     636             :                 // TODO: verify if we really need to increment nSuffix in 2 places
     637           0 :                 aName = aBaseName + OUString::number(++nSuffix);
     638           0 :             }
     639             :         }
     640             : 
     641           0 :         m_rExport.AttrOutput().StartStyle( aName, (bFmtColl ? STYLE_TYPE_PARA : STYLE_TYPE_CHAR),
     642           0 :                 nBase, nWwNext, GetWWId( *pFmt ), nPos,
     643           0 :                 pFmt->IsAutoUpdateFmt() );
     644             : 
     645           0 :         if ( bFmtColl )
     646           0 :             WriteProperties( pFmt, true, nPos, nBase==0xfff );           // UPX.papx
     647             : 
     648           0 :         WriteProperties( pFmt, false, nPos, bFmtColl && nBase==0xfff );  // UPX.chpx
     649             : 
     650           0 :         m_rExport.AttrOutput().EndStyle();
     651             :     }
     652           0 : }
     653             : 
     654           0 : void WW8AttributeOutput::StartStyles()
     655             : {
     656           0 :     WW8Fib& rFib = *m_rWW8Export.pFib;
     657             : 
     658           0 :     sal_uLong nCurPos = m_rWW8Export.pTableStrm->Tell();
     659           0 :     if ( nCurPos & 1 )                   // Start auf gerader
     660             :     {
     661           0 :         m_rWW8Export.pTableStrm->WriteChar( (char)0 );        // Address
     662           0 :         ++nCurPos;
     663             :     }
     664           0 :     rFib.fcStshfOrig = rFib.fcStshf = nCurPos;
     665           0 :     m_nStyAnzPos = nCurPos + 2;     // Anzahl wird nachgetragen
     666             : 
     667           0 :     if ( m_rWW8Export.bWrtWW8 )
     668             :     {
     669             :         static sal_uInt8 aStShi[] = {
     670             :             0x12, 0x00,
     671             :             0x0F, 0x00, 0x0A, 0x00, 0x01, 0x00, 0x5B, 0x00,
     672             :             0x0F, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
     673             :             0x00, 0x00 };
     674             : 
     675           0 :         m_rWW8Export.pTableStrm->Write( &aStShi, sizeof( aStShi ) );
     676             :     }
     677             :     else
     678             :     {
     679             :         static sal_uInt8 aStShi[] = {
     680             :             0x0E, 0x00,
     681             :             0x0F, 0x00, 0x08, 0x00, 0x01, 0x00, 0x4B, 0x00,
     682             :             0x0F, 0x00, 0x00, 0x00, 0x00, 0x00 };
     683           0 :         m_rWW8Export.pTableStrm->Write( &aStShi, sizeof( aStShi ) );
     684             :     }
     685           0 : }
     686             : 
     687           0 : void WW8AttributeOutput::EndStyles( sal_uInt16 nNumberOfStyles )
     688             : {
     689           0 :     WW8Fib& rFib = *m_rWW8Export.pFib;
     690             : 
     691           0 :     rFib.lcbStshfOrig = rFib.lcbStshf = m_rWW8Export.pTableStrm->Tell() - rFib.fcStshf;
     692           0 :     SwWW8Writer::WriteShort( *m_rWW8Export.pTableStrm, m_nStyAnzPos, nNumberOfStyles );
     693           0 : }
     694             : 
     695           0 : void MSWordStyles::OutputStylesTable()
     696             : {
     697           0 :     m_rExport.bStyDef = true;
     698             : 
     699           0 :     m_rExport.AttrOutput().StartStyles();
     700             : 
     701             :     sal_uInt16 n;
     702             :     // HACK
     703             :     // Ms Office seems to have an internal limitation of 4091 styles
     704             :     // and refuses to load .docx with more, even though the spec seems to allow that;
     705             :     // so simply if there are more styles, don't export those
     706             :     // Implementing check for all exports DOCX, DOC, RTF
     707           0 :     sal_uInt16 nLimit = MSWORD_MAX_STYLES_LIMIT;
     708           0 :     nUsedSlots = (nLimit > nUsedSlots)? nUsedSlots : nLimit;
     709             : 
     710           0 :     for ( n = 0; n < nUsedSlots; n++ )
     711             :     {
     712           0 :         if (m_aNumRules.find(n) != m_aNumRules.end())
     713           0 :             OutputStyle(m_aNumRules[n], n);
     714             :         else
     715           0 :             OutputStyle( pFmtA[n], n );
     716             :     }
     717             : 
     718           0 :     m_rExport.AttrOutput().EndStyles( nUsedSlots );
     719             : 
     720           0 :     m_rExport.bStyDef = false;
     721           0 : }
     722             : 
     723           0 : const SwNumRule* MSWordStyles::GetSwNumRule(sal_uInt16 nId) const
     724             : {
     725           0 :     std::map<sal_uInt16, const SwNumRule*>::const_iterator it = m_aNumRules.find(nId);
     726             :     assert(it != m_aNumRules.end());
     727           0 :     return it->second;
     728             : }
     729             : 
     730             : //          Fonts
     731             : 
     732           0 : wwFont::wwFont(const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily,
     733           0 :     rtl_TextEncoding eChrSet, bool bWrtWW8) : mbAlt(false), mbWrtWW8(bWrtWW8), mePitch(ePitch), meFamily(eFamily), meChrSet(eChrSet)
     734             : {
     735           0 :     FontMapExport aResult(rFamilyName);
     736           0 :     msFamilyNm = aResult.msPrimary;
     737           0 :     msAltNm = aResult.msSecondary;
     738           0 :     if (!msAltNm.isEmpty() && msAltNm != msFamilyNm &&
     739           0 :         (msFamilyNm.getLength() + msAltNm.getLength() + 2 <= 65) )
     740             :     {
     741             :         //max size of szFfn in 65 chars
     742           0 :         mbAlt = true;
     743             :     }
     744             : 
     745           0 :     memset(maWW8_FFN, 0, sizeof(maWW8_FFN));
     746             : 
     747           0 :     if (bWrtWW8)
     748             :     {
     749           0 :         maWW8_FFN[0] = (sal_uInt8)( 6 - 1 + 0x22 + ( 2 * ( 1 + msFamilyNm.getLength() ) ));
     750           0 :         if (mbAlt)
     751           0 :             maWW8_FFN[0] = static_cast< sal_uInt8 >(maWW8_FFN[0] + 2 * ( 1 + msAltNm.getLength()));
     752             :     }
     753             :     else
     754             :     {
     755           0 :         maWW8_FFN[0] = (sal_uInt8)( 6 - 1 + 1 + msFamilyNm.getLength() );
     756           0 :         if (mbAlt)
     757           0 :             maWW8_FFN[0] = static_cast< sal_uInt8 >(maWW8_FFN[0] + 1 + msAltNm.getLength());
     758             :     }
     759             : 
     760           0 :     sal_uInt8 aB = 0;
     761           0 :     switch(ePitch)
     762             :     {
     763             :         case PITCH_VARIABLE:
     764           0 :             aB |= 2;    // aF.prg = 2
     765           0 :             break;
     766             :         case PITCH_FIXED:
     767           0 :             aB |= 1;
     768           0 :             break;
     769             :         default:        // aF.prg = 0 : DEFAULT_PITCH (windows.h)
     770           0 :             break;
     771             :     }
     772           0 :     aB |= 1 << 2;   // aF.fTrueType = 1; don't know any better;
     773             : 
     774           0 :     switch(eFamily)
     775             :     {
     776             :         case FAMILY_ROMAN:
     777           0 :             aB |= 1 << 4;   // aF.ff = 1;
     778           0 :             break;
     779             :         case FAMILY_SWISS:
     780           0 :             aB |= 2 << 4;   // aF.ff = 2;
     781           0 :             break;
     782             :         case FAMILY_MODERN:
     783           0 :             aB |= 3 << 4;   // aF.ff = 3;
     784           0 :             break;
     785             :         case FAMILY_SCRIPT:
     786           0 :             aB |= 4 << 4;   // aF.ff = 4;
     787           0 :             break;
     788             :         case FAMILY_DECORATIVE:
     789           0 :             aB |= 5 << 4;   // aF.ff = 5;
     790           0 :             break;
     791             :         default:            // aF.ff = 0; FF_DONTCARE (windows.h)
     792           0 :             break;
     793             :     }
     794           0 :     maWW8_FFN[1] = aB;
     795             : 
     796           0 :     ShortToSVBT16( 400, &maWW8_FFN[2] );        // don't know any better
     797             :                                                 // 400 == FW_NORMAL (windows.h)
     798             : 
     799             :     //#i61927# For unicode fonts like Arial Unicode, Word 97+ sets the chs
     800             :     //to SHIFTJIS presumably to capture that it's a multi-byte encoding font
     801             :     //but Word95 doesn't do this, and sets it to 0 (ANSI), so we should do the
     802             :     //same
     803             :     maWW8_FFN[4] = bWrtWW8 ?
     804           0 :         sw::ms::rtl_TextEncodingToWinCharset(eChrSet) :
     805           0 :         rtl_getBestWindowsCharsetFromTextEncoding(eChrSet);
     806             : 
     807           0 :     if (mbAlt)
     808           0 :         maWW8_FFN[5] = static_cast< sal_uInt8 >(msFamilyNm.getLength() + 1);
     809           0 : }
     810             : 
     811           0 : bool wwFont::Write(SvStream *pTableStrm) const
     812             : {
     813           0 :     pTableStrm->Write(maWW8_FFN, sizeof(maWW8_FFN));    // fixed part
     814           0 :     if (mbWrtWW8)
     815             :     {
     816             :         // ab Ver8 sind folgende beiden Felder eingeschoben,
     817             :         // werden von uns ignoriert.
     818             :         //char  panose[ 10 ];       //  0x6   PANOSE
     819             :         //char  fs[ 24     ];       //  0x10  FONTSIGNATURE
     820           0 :         SwWW8Writer::FillCount(*pTableStrm, 0x22);
     821           0 :         SwWW8Writer::WriteString16(*pTableStrm, msFamilyNm, true);
     822           0 :         if (mbAlt)
     823           0 :             SwWW8Writer::WriteString16(*pTableStrm, msAltNm, true);
     824             :     }
     825             :     else
     826             :     {
     827             :         SwWW8Writer::WriteString8(*pTableStrm, msFamilyNm, true,
     828           0 :             RTL_TEXTENCODING_MS_1252);
     829           0 :         if (mbAlt)
     830             :         {
     831             :             SwWW8Writer::WriteString8( *pTableStrm, msAltNm, true,
     832           0 :                 RTL_TEXTENCODING_MS_1252);
     833             :         }
     834             :     }
     835           0 :     return true;
     836             : }
     837             : 
     838           0 : void wwFont::WriteDocx( DocxAttributeOutput* rAttrOutput ) const
     839             : {
     840             :     // no font embedding, panose id, subsetting, ... implemented
     841             : 
     842           0 :     if (!msFamilyNm.isEmpty())
     843             :     {
     844           0 :         rAttrOutput->StartFont( msFamilyNm );
     845             : 
     846           0 :         if ( mbAlt )
     847           0 :             rAttrOutput->FontAlternateName( msAltNm );
     848           0 :         rAttrOutput->FontCharset( sw::ms::rtl_TextEncodingToWinCharset( meChrSet ), meChrSet );
     849           0 :         rAttrOutput->FontFamilyType( meFamily );
     850           0 :         rAttrOutput->FontPitchType( mePitch );
     851           0 :         rAttrOutput->EmbedFont( msFamilyNm, meFamily, mePitch, meChrSet );
     852             : 
     853           0 :         rAttrOutput->EndFont();
     854             :     }
     855           0 : }
     856             : 
     857           0 : void wwFont::WriteRtf( const RtfAttributeOutput* rAttrOutput ) const
     858             : {
     859           0 :     rAttrOutput->FontFamilyType( meFamily, *this );
     860           0 :     rAttrOutput->FontPitchType( mePitch );
     861           0 :     rAttrOutput->FontCharset( rtl_getBestWindowsCharsetFromTextEncoding( meChrSet ) );
     862           0 :     rAttrOutput->StartFont( msFamilyNm );
     863           0 :     if ( mbAlt )
     864           0 :         rAttrOutput->FontAlternateName( msAltNm );
     865           0 :     rAttrOutput->EndFont();
     866           0 : }
     867             : 
     868           0 : bool operator<(const wwFont &r1, const wwFont &r2)
     869             : {
     870           0 :     int nRet = memcmp(r1.maWW8_FFN, r2.maWW8_FFN, sizeof(r1.maWW8_FFN));
     871           0 :     if (nRet == 0)
     872             :     {
     873           0 :         nRet = r1.msFamilyNm.compareTo(r2.msFamilyNm);
     874           0 :         if (nRet == 0)
     875           0 :             nRet = r1.msAltNm.compareTo(r2.msAltNm);
     876             :     }
     877           0 :     return nRet < 0;
     878             : }
     879             : 
     880           0 : sal_uInt16 wwFontHelper::GetId(const wwFont &rFont)
     881             : {
     882             :     sal_uInt16 nRet;
     883           0 :     ::std::map<wwFont, sal_uInt16>::const_iterator aIter = maFonts.find(rFont);
     884           0 :     if (aIter != maFonts.end())
     885           0 :         nRet = aIter->second;
     886             :     else
     887             :     {
     888           0 :         nRet = static_cast< sal_uInt16 >(maFonts.size());
     889           0 :         maFonts[rFont] = nRet;
     890             :     }
     891           0 :     return nRet;
     892             : }
     893             : 
     894           0 : void wwFontHelper::InitFontTable(bool bWrtWW8,const SwDoc& rDoc)
     895             : {
     896           0 :     mbWrtWW8 = bWrtWW8;
     897             : 
     898             :     GetId(wwFont(OUString("Times New Roman"), PITCH_VARIABLE,
     899           0 :         FAMILY_ROMAN, RTL_TEXTENCODING_MS_1252,bWrtWW8));
     900             : 
     901             :     GetId(wwFont(OUString("Symbol"), PITCH_VARIABLE, FAMILY_ROMAN,
     902           0 :         RTL_TEXTENCODING_SYMBOL,bWrtWW8));
     903             : 
     904             :     GetId(wwFont(OUString("Arial"), PITCH_VARIABLE, FAMILY_SWISS,
     905           0 :         RTL_TEXTENCODING_MS_1252,bWrtWW8));
     906             : 
     907           0 :     const SvxFontItem* pFont = (const SvxFontItem*)GetDfltAttr(RES_CHRATR_FONT);
     908             : 
     909           0 :     GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
     910           0 :         pFont->GetFamily(), pFont->GetCharSet(),bWrtWW8));
     911             : 
     912           0 :     const SfxItemPool& rPool = rDoc.GetAttrPool();
     913           0 :     if (0 != (pFont = (const SvxFontItem*)rPool.GetPoolDefaultItem(RES_CHRATR_FONT)))
     914             :     {
     915           0 :         GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
     916           0 :             pFont->GetFamily(), pFont->GetCharSet(),bWrtWW8));
     917             :     }
     918             : 
     919           0 :     if (!bLoadAllFonts)
     920           0 :         return;
     921             : 
     922           0 :     const sal_uInt16 aTypes[] = { RES_CHRATR_FONT, RES_CHRATR_CJK_FONT, RES_CHRATR_CTL_FONT, 0 };
     923           0 :     for (const sal_uInt16* pId = aTypes; *pId; ++pId)
     924             :     {
     925           0 :         sal_uInt32 const nMaxItem = rPool.GetItemCount2( *pId );
     926           0 :         for (sal_uInt32 nGet = 0; nGet < nMaxItem; ++nGet)
     927             :         {
     928           0 :             pFont = (const SvxFontItem*)rPool.GetItem2( *pId, nGet );
     929           0 :             if (0 != pFont)
     930             :             {
     931           0 :                 GetId(wwFont(pFont->GetFamilyName(), pFont->GetPitch(),
     932           0 :                             pFont->GetFamily(), pFont->GetCharSet(),bWrtWW8));
     933             :             }
     934             :         }
     935             :     }
     936             : }
     937             : 
     938           0 : sal_uInt16 wwFontHelper::GetId(const Font& rFont)
     939             : {
     940           0 :     wwFont aFont(rFont.GetName(), rFont.GetPitch(), rFont.GetFamily(),
     941           0 :         rFont.GetCharSet(), mbWrtWW8);
     942           0 :     return GetId(aFont);
     943             : }
     944             : 
     945           0 : sal_uInt16 wwFontHelper::GetId(const SvxFontItem& rFont)
     946             : {
     947           0 :     wwFont aFont(rFont.GetFamilyName(), rFont.GetPitch(), rFont.GetFamily(),
     948           0 :         rFont.GetCharSet(), mbWrtWW8);
     949           0 :     return GetId(aFont);
     950             : }
     951             : 
     952           0 : ::std::vector< const wwFont* > wwFontHelper::AsVector() const
     953             : {
     954           0 :     ::std::vector<const wwFont *> aFontList( maFonts.size() );
     955             : 
     956             :     typedef ::std::map<wwFont, sal_uInt16>::const_iterator myiter;
     957           0 :     myiter aEnd = maFonts.end();
     958           0 :     for ( myiter aIter = maFonts.begin(); aIter != aEnd; ++aIter )
     959           0 :         aFontList[aIter->second] = &aIter->first;
     960             : 
     961           0 :     return aFontList;
     962             : }
     963             : 
     964           0 : void wwFontHelper::WriteFontTable(SvStream *pTableStream, WW8Fib& rFib)
     965             : {
     966           0 :     rFib.fcSttbfffn = pTableStream->Tell();
     967             :     /*
     968             :      * Reserve some space to fill in the len after we know how big it is
     969             :      */
     970           0 :     if (mbWrtWW8)
     971           0 :         SwWW8Writer::WriteLong(*pTableStream, 0);
     972             :     else
     973           0 :         SwWW8Writer::WriteShort(*pTableStream, 0);
     974             : 
     975             :     /*
     976             :      * Convert from fast insertion map to linear vector in the order that we
     977             :      * want to write.
     978             :      */
     979           0 :     ::std::vector<const wwFont *> aFontList( AsVector() );
     980             : 
     981             :     /*
     982             :      * Write them all to pTableStream
     983             :      */
     984             :     ::std::for_each(aFontList.begin(), aFontList.end(),
     985           0 :         ::std::bind2nd(::std::mem_fun(&wwFont::Write),pTableStream));
     986             : 
     987             :     /*
     988             :      * Write the position and len in the FIB
     989             :      */
     990           0 :     rFib.lcbSttbfffn = pTableStream->Tell() - rFib.fcSttbfffn;
     991           0 :     if (mbWrtWW8)
     992           0 :         SwWW8Writer::WriteLong( *pTableStream, rFib.fcSttbfffn, maFonts.size());
     993             :     else
     994             :     {
     995             :         SwWW8Writer::WriteShort( *pTableStream, rFib.fcSttbfffn,
     996           0 :             (sal_Int16)rFib.lcbSttbfffn );
     997           0 :     }
     998           0 : }
     999             : 
    1000           0 : void wwFontHelper::WriteFontTable( DocxAttributeOutput& rAttrOutput )
    1001             : {
    1002           0 :     ::std::vector<const wwFont *> aFontList( AsVector() );
    1003             : 
    1004             :     ::std::for_each( aFontList.begin(), aFontList.end(),
    1005           0 :         ::std::bind2nd( ::std::mem_fun( &wwFont::WriteDocx ), &rAttrOutput ) );
    1006           0 : }
    1007             : 
    1008           0 : void wwFontHelper::WriteFontTable( const RtfAttributeOutput& rAttrOutput )
    1009             : {
    1010           0 :     ::std::vector<const wwFont *> aFontList( AsVector() );
    1011             : 
    1012             :     ::std::for_each( aFontList.begin(), aFontList.end(),
    1013           0 :         ::std::bind2nd( ::std::mem_fun( &wwFont::WriteRtf ), &rAttrOutput ) );
    1014           0 : }
    1015             : 
    1016           0 : WW8_WrPlc0::WW8_WrPlc0( sal_uLong nOffset )
    1017           0 :     : nOfs( nOffset )
    1018             : {
    1019           0 : }
    1020             : 
    1021           0 : void WW8_WrPlc0::Append( sal_uLong nStartCpOrFc )
    1022             : {
    1023           0 :     aPos.push_back( nStartCpOrFc - nOfs );
    1024           0 : }
    1025             : 
    1026           0 : void WW8_WrPlc0::Write( SvStream& rStrm )
    1027             : {
    1028           0 :     std::vector<sal_uLong>::const_iterator iter;
    1029           0 :     for( iter = aPos.begin(); iter != aPos.end(); ++iter )
    1030             :     {
    1031             :         SVBT32 nP;
    1032           0 :         UInt32ToSVBT32( *iter, nP );
    1033           0 :         rStrm.Write( nP, 4 );
    1034             :     }
    1035           0 : }
    1036             : 
    1037             : // class MSWordSections : translate PageDescs into Sections
    1038             : //      also deals with header and footer
    1039             : 
    1040           0 : MSWordSections::MSWordSections( MSWordExportBase& rExport )
    1041           0 :     : mbDocumentIsProtected( false )
    1042             : {
    1043           0 :     const SwSectionFmt *pFmt = 0;
    1044           0 :     rExport.pAktPageDesc = &rExport.pDoc->GetPageDesc( 0 );
    1045             : 
    1046             :     const SfxPoolItem* pI;
    1047           0 :     const SwNode* pNd = rExport.pCurPam->GetCntntNode();
    1048           0 :     const SfxItemSet* pSet = pNd ? &((SwCntntNode*)pNd)->GetSwAttrSet() : 0;
    1049             : 
    1050           0 :     sal_uLong nRstLnNum =  pSet ? ((SwFmtLineNumber&)pSet->Get( RES_LINENUMBER )).GetStartValue() : 0;
    1051             : 
    1052           0 :     const SwTableNode* pTblNd = rExport.pCurPam->GetNode()->FindTableNode();
    1053             :     const SwSectionNode* pSectNd;
    1054           0 :     if ( pTblNd )
    1055             :     {
    1056           0 :         pSet = &pTblNd->GetTable().GetFrmFmt()->GetAttrSet();
    1057           0 :         pNd = pTblNd;
    1058             :     }
    1059           0 :     else if (pNd && 0 != ( pSectNd = pNd->FindSectionNode() ))
    1060             :     {
    1061           0 :         if ( TOX_HEADER_SECTION == pSectNd->GetSection().GetType() &&
    1062           0 :              pSectNd->StartOfSectionNode()->IsSectionNode() )
    1063             :         {
    1064           0 :             pSectNd = pSectNd->StartOfSectionNode()->GetSectionNode();
    1065             :         }
    1066             : 
    1067           0 :         if ( TOX_CONTENT_SECTION == pSectNd->GetSection().GetType() )
    1068             :         {
    1069           0 :             pNd = pSectNd;
    1070           0 :             rExport.pCurPam->GetPoint()->nNode = *pNd;
    1071             :         }
    1072             : 
    1073           0 :         if ( CONTENT_SECTION == pSectNd->GetSection().GetType() )
    1074           0 :             pFmt = pSectNd->GetSection().GetFmt();
    1075             :     }
    1076             : 
    1077             :     // Hole evtl. Pagedesc des 1. Nodes
    1078           0 :     if ( pSet &&
    1079           0 :          SFX_ITEM_ON == pSet->GetItemState( RES_PAGEDESC, true, &pI ) &&
    1080           0 :          ( (SwFmtPageDesc*)pI )->GetPageDesc() )
    1081             :     {
    1082           0 :         AppendSection( *(SwFmtPageDesc*)pI, *pNd, pFmt, nRstLnNum );
    1083             :     }
    1084             :     else
    1085           0 :         AppendSection( rExport.pAktPageDesc, pFmt, nRstLnNum );
    1086           0 : }
    1087             : 
    1088           0 : WW8_WrPlcSepx::WW8_WrPlcSepx( MSWordExportBase& rExport )
    1089             :     : MSWordSections( rExport )
    1090             :     , m_bHeaderFooterWritten( false )
    1091           0 :     , pTxtPos( 0 )
    1092             : {
    1093             :     // to be in sync with the AppendSection() call in the MSWordSections
    1094             :     // constructor
    1095           0 :     aCps.push_back( 0 );
    1096           0 : }
    1097             : 
    1098           0 : MSWordSections::~MSWordSections()
    1099             : {
    1100           0 : }
    1101             : 
    1102           0 : WW8_WrPlcSepx::~WW8_WrPlcSepx()
    1103             : {
    1104           0 :     delete pTxtPos;
    1105           0 : }
    1106             : 
    1107           0 : bool MSWordSections::HeaderFooterWritten()
    1108             : {
    1109           0 :     return false; // only relevant for WW8
    1110             : }
    1111             : 
    1112           0 : bool WW8_WrPlcSepx::HeaderFooterWritten()
    1113             : {
    1114           0 :     return m_bHeaderFooterWritten;
    1115             : }
    1116             : 
    1117           0 : sal_uInt16 MSWordSections::CurrentNumberOfColumns( const SwDoc &rDoc ) const
    1118             : {
    1119             :     OSL_ENSURE( !aSects.empty(), "no segement inserted yet" );
    1120           0 :     if ( aSects.empty() )
    1121           0 :         return 1;
    1122             : 
    1123           0 :     return NumberOfColumns( rDoc, aSects.back() );
    1124             : }
    1125             : 
    1126           0 : sal_uInt16 MSWordSections::NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const
    1127             : {
    1128           0 :     const SwPageDesc* pPd = rInfo.pPageDesc;
    1129           0 :     if ( !pPd )
    1130           0 :         pPd = &rDoc.GetPageDesc( 0 );
    1131             : 
    1132           0 :     if ( !pPd )
    1133             :     {
    1134             :         OSL_ENSURE( pPd, "totally impossible" );
    1135           0 :         return 1;
    1136             :     }
    1137             : 
    1138           0 :     const SfxItemSet &rSet = pPd->GetMaster().GetAttrSet();
    1139           0 :     SfxItemSet aSet( *rSet.GetPool(), RES_COL, RES_COL );
    1140           0 :     aSet.SetParent( &rSet );
    1141             : 
    1142             :     //0xffffffff, what the hell is going on with that!, fixme most terribly
    1143           0 :     if ( rInfo.pSectionFmt && (SwSectionFmt*)0xFFFFFFFF != rInfo.pSectionFmt )
    1144           0 :         aSet.Put( rInfo.pSectionFmt->GetFmtAttr( RES_COL ) );
    1145             : 
    1146           0 :     const SwFmtCol& rCol = (const SwFmtCol&)aSet.Get( RES_COL );
    1147           0 :     const SwColumns& rColumns = rCol.GetColumns();
    1148           0 :     return rColumns.size();
    1149             : }
    1150             : 
    1151           0 : const WW8_SepInfo* MSWordSections::CurrentSectionInfo()
    1152             : {
    1153           0 :     if ( !aSects.empty() )
    1154           0 :         return &aSects.back();
    1155             : 
    1156           0 :     return NULL;
    1157             : }
    1158             : 
    1159           0 : void MSWordSections::AppendSection( const SwPageDesc* pPd,
    1160             :     const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo )
    1161             : {
    1162           0 :     if (HeaderFooterWritten()) {
    1163           0 :         return; // #i117955# prevent new sections in endnotes
    1164             :     }
    1165           0 :     aSects.push_back( WW8_SepInfo( pPd, pSectionFmt, nLnNumRestartNo ) );
    1166           0 :     NeedsDocumentProtected( aSects.back() );
    1167             : }
    1168             : 
    1169           0 : void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwPageDesc* pPd,
    1170             :     const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo )
    1171             : {
    1172           0 :     if (HeaderFooterWritten()) {
    1173           0 :         return; // #i117955# prevent new sections in endnotes
    1174             :     }
    1175           0 :     aCps.push_back( nStartCp );
    1176           0 :     AppendSection( pPd, pSectionFmt, nLnNumRestartNo );
    1177             : }
    1178             : 
    1179           0 : void MSWordSections::AppendSection( const SwFmtPageDesc& rPD,
    1180             :     const SwNode& rNd, const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo )
    1181             : {
    1182           0 :     if (HeaderFooterWritten()) {
    1183           0 :         return; // #i117955# prevent new sections in endnotes
    1184             :     }
    1185             : 
    1186           0 :     WW8_SepInfo aI( rPD.GetPageDesc(), pSectionFmt, nLnNumRestartNo, rPD.GetNumOffset(), &rNd );
    1187             : 
    1188           0 :     aSects.push_back( aI );
    1189           0 :     NeedsDocumentProtected( aI );
    1190             : }
    1191             : 
    1192           0 : void WW8_WrPlcSepx::AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPD,
    1193             :     const SwNode& rNd, const SwSectionFmt* pSectionFmt, sal_uLong nLnNumRestartNo )
    1194             : {
    1195           0 :     if (HeaderFooterWritten()) {
    1196           0 :         return; // #i117955# prevent new sections in endnotes
    1197             :     }
    1198           0 :     aCps.push_back( nStartCp );
    1199           0 :     AppendSection( rPD, rNd, pSectionFmt, nLnNumRestartNo );
    1200             : }
    1201             : 
    1202             : // MSWordSections::SetNum() sets in each section the Num-pointers for the first call.
    1203             : // All subsequent calls will be ignored.
    1204             : // Thus, the first list of the section will be adopted.
    1205             : 
    1206           0 : void MSWordSections::SetNum( const SwTxtNode* pNumNd )
    1207             : {
    1208           0 :     WW8_SepInfo& rInfo = aSects.back();
    1209           0 :     if ( !rInfo.pNumNd ) // not yet assigned
    1210           0 :         rInfo.pNumNd = pNumNd;
    1211           0 : }
    1212             : 
    1213           0 : void WW8_WrPlcSepx::WriteFtnEndTxt( WW8Export& rWrt, sal_uLong nCpStt )
    1214             : {
    1215           0 :     sal_uInt8 nInfoFlags = 0;
    1216           0 :     const SwFtnInfo& rInfo = rWrt.pDoc->GetFtnInfo();
    1217           0 :     if( !rInfo.aErgoSum.isEmpty() )  nInfoFlags |= 0x02;
    1218           0 :     if( !rInfo.aQuoVadis.isEmpty() ) nInfoFlags |= 0x04;
    1219             : 
    1220           0 :     sal_uInt8 nEmptyStt = rWrt.bWrtWW8 ? 0 : 6;
    1221           0 :     if( nInfoFlags )
    1222             :     {
    1223           0 :         if( rWrt.bWrtWW8 )
    1224           0 :             pTxtPos->Append( nCpStt );  // empty footnote separator
    1225             : 
    1226           0 :         if( 0x02 & nInfoFlags )         // Footnote continuation separator
    1227             :         {
    1228           0 :             pTxtPos->Append( nCpStt );
    1229           0 :             rWrt.WriteStringAsPara( rInfo.aErgoSum );
    1230           0 :             rWrt.WriteStringAsPara( OUString() );
    1231           0 :             nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1232             :         }
    1233           0 :         else if( rWrt.bWrtWW8 )
    1234           0 :             pTxtPos->Append( nCpStt );
    1235             : 
    1236           0 :         if( 0x04 & nInfoFlags )         // Footnote continuation notice
    1237             :         {
    1238           0 :             pTxtPos->Append( nCpStt );
    1239           0 :             rWrt.WriteStringAsPara( rInfo.aQuoVadis );
    1240           0 :             rWrt.WriteStringAsPara( OUString() );
    1241           0 :             nCpStt = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1242             :         }
    1243           0 :         else if( rWrt.bWrtWW8 )
    1244           0 :             pTxtPos->Append( nCpStt );
    1245             : 
    1246           0 :         if( rWrt.bWrtWW8 )
    1247           0 :             nEmptyStt = 3;
    1248             :         else
    1249           0 :             rWrt.pDop->grpfIhdt = nInfoFlags;
    1250             :     }
    1251             : 
    1252           0 :     while( 6 > nEmptyStt++ )
    1253           0 :         pTxtPos->Append( nCpStt );
    1254             : 
    1255             :     // gleich die Flags am Dop setzen
    1256           0 :     WW8Dop& rDop = *rWrt.pDop;
    1257             :     // Footnote Info
    1258           0 :     switch( rInfo.eNum )
    1259             :     {
    1260           0 :     case FTNNUM_PAGE:       rDop.rncFtn = 2; break;
    1261           0 :     case FTNNUM_CHAPTER:    rDop.rncFtn  = 1; break;
    1262           0 :     default: rDop.rncFtn  = 0; break;
    1263             :     }                                   // rncFtn
    1264           0 :     rDop.nfcFtnRef = WW8Export::GetNumId( rInfo.aFmt.GetNumberingType() );
    1265           0 :     rDop.nFtn = rInfo.nFtnOffset + 1;
    1266           0 :     rDop.fpc = rWrt.bFtnAtTxtEnd ? 2 : 1;
    1267             : 
    1268             :     // Endnote Info
    1269           0 :     rDop.rncEdn = 0;                        // rncEdn: Don't Restart
    1270           0 :     const SwEndNoteInfo& rEndInfo = rWrt.pDoc->GetEndNoteInfo();
    1271           0 :     rDop.nfcEdnRef = WW8Export::GetNumId( rEndInfo.aFmt.GetNumberingType() );
    1272           0 :     rDop.nEdn = rEndInfo.nFtnOffset + 1;
    1273           0 :     rDop.epc = rWrt.bEndAtTxtEnd ? 3 : 0;
    1274           0 : }
    1275             : 
    1276           0 : void MSWordSections::SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
    1277             :     sal_uInt8 nFlag )
    1278             : {
    1279             :     const SfxPoolItem* pItem;
    1280           0 :     if( SFX_ITEM_SET == rFmt.GetItemState(RES_HEADER, true, &pItem)
    1281           0 :         && ((SwFmtHeader*)pItem)->IsActive() &&
    1282           0 :         ((SwFmtHeader*)pItem)->GetHeaderFmt() )
    1283           0 :         rHeadFootFlags |= nFlag;
    1284           0 : }
    1285             : 
    1286           0 : void MSWordSections::SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
    1287             :     sal_uInt8 nFlag )
    1288             : {
    1289             :     const SfxPoolItem* pItem;
    1290           0 :     if( SFX_ITEM_SET == rFmt.GetItemState(RES_FOOTER, true, &pItem)
    1291           0 :         && ((SwFmtFooter*)pItem)->IsActive() &&
    1292           0 :         ((SwFmtFooter*)pItem)->GetFooterFmt() )
    1293           0 :         rHeadFootFlags |= nFlag;
    1294           0 : }
    1295             : 
    1296           0 : void WW8_WrPlcSepx::OutHeaderFooter( WW8Export& rWrt, bool bHeader,
    1297             :                      const SwFmt& rFmt, sal_uLong& rCpPos, sal_uInt8 nHFFlags,
    1298             :                      sal_uInt8 nFlag,  sal_uInt8 nBreakCode)
    1299             : {
    1300           0 :     if ( nFlag & nHFFlags )
    1301             :     {
    1302           0 :         pTxtPos->Append( rCpPos );
    1303           0 :         rWrt.WriteHeaderFooterText( rFmt, bHeader);
    1304           0 :         rWrt.WriteStringAsPara( OUString() ); // CR ans Ende ( sonst mault WW )
    1305           0 :         rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1306             :     }
    1307           0 :     else if ( rWrt.bWrtWW8 )
    1308             :     {
    1309           0 :         pTxtPos->Append( rCpPos );
    1310           0 :         if ((bHeader? rWrt.bHasHdr : rWrt.bHasFtr) && nBreakCode!=0)
    1311             :         {
    1312           0 :             rWrt.WriteStringAsPara( OUString() ); // Empty paragraph for empty header/footer
    1313           0 :             rWrt.WriteStringAsPara( OUString() ); // a CR that WW8 needs for end of the stream
    1314           0 :             rCpPos = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1315             :         }
    1316             :     }
    1317           0 : }
    1318             : 
    1319           0 : void MSWordSections::NeedsDocumentProtected(const WW8_SepInfo &rInfo)
    1320             : {
    1321           0 :     if (rInfo.IsProtected())
    1322           0 :         mbDocumentIsProtected = true;
    1323           0 : }
    1324             : 
    1325           0 : bool WW8_SepInfo::IsProtected() const
    1326             : {
    1327           0 :     bool bRet = false;
    1328           0 :     if (
    1329           0 :          pSectionFmt &&
    1330           0 :          ((SwSectionFmt*)0xFFFFFFFF != pSectionFmt)
    1331             :        )
    1332             :     {
    1333           0 :         const SwSection *pSection = pSectionFmt->GetSection();
    1334           0 :         if (pSection && pSection->IsProtect())
    1335             :         {
    1336           0 :             bRet = true;
    1337             :         }
    1338             :     }
    1339           0 :     return bRet;
    1340             : }
    1341             : 
    1342           0 : void MSWordSections::CheckForFacinPg( WW8Export& rWrt ) const
    1343             : {
    1344             :     // 2 values getting set
    1345             :     //      Dop.fFacingPages            == Header and Footer different
    1346             :     //      Dop.fSwapBordersFacingPgs   == mirrored borders
    1347           0 :     std::vector<WW8_SepInfo>::const_iterator iter = aSects.begin();
    1348           0 :     for( sal_uInt16 nEnde = 0; iter != aSects.end(); ++iter )
    1349             :     {
    1350           0 :         const WW8_SepInfo& rSepInfo = *iter;
    1351           0 :         if( !rSepInfo.pSectionFmt )
    1352             :         {
    1353           0 :             const SwPageDesc* pPd = rSepInfo.pPageDesc;
    1354           0 :             if( pPd->GetFollow() && pPd != pPd->GetFollow() &&
    1355           0 :                 pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
    1356           0 :                 rSepInfo.pPDNd &&
    1357           0 :                 pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) )
    1358             :                 // das ist also 1.Seite und nachfolgende, also nur den
    1359             :                 // follow beachten
    1360           0 :                 pPd = pPd->GetFollow();
    1361             : 
    1362             :             // left-/right chain of pagedescs ?
    1363           0 :             else if( !( 1 & nEnde ) &&
    1364           0 :                 pPd->GetFollow() && pPd != pPd->GetFollow() &&
    1365           0 :                 pPd->GetFollow()->GetFollow() == pPd &&
    1366           0 :                 (( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) &&
    1367           0 :                    nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) ||
    1368           0 :                  ( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) &&
    1369           0 :                    nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) ))
    1370             :             {
    1371           0 :                 rWrt.pDop->fFacingPages = rWrt.pDop->fMirrorMargins = true;
    1372           0 :                 nEnde |= 1;
    1373             :             }
    1374             : 
    1375           0 :             if( !( 1 & nEnde ) &&
    1376           0 :                 ( !pPd->IsHeaderShared() || !pPd->IsFooterShared() ))
    1377             :             {
    1378           0 :                 rWrt.pDop->fFacingPages = true;
    1379           0 :                 nEnde |= 1;
    1380             :             }
    1381           0 :             if( !( 2 & nEnde ) &&
    1382           0 :                 nsUseOnPage::PD_MIRROR == ( nsUseOnPage::PD_MIRROR & pPd->ReadUseOn() ))
    1383             :             {
    1384             :                 rWrt.pDop->fSwapBordersFacingPgs =
    1385           0 :                     rWrt.pDop->fMirrorMargins = true;
    1386           0 :                 nEnde |= 2;
    1387             :             }
    1388             : 
    1389           0 :             if( 3 == nEnde )
    1390           0 :                 break;      // We do not need to go any further
    1391             :         }
    1392             :     }
    1393           0 : }
    1394             : 
    1395           0 : bool MSWordSections::HasBorderItem( const SwFmt& rFmt )
    1396             : {
    1397             :     const SfxPoolItem* pItem;
    1398           0 :     return SFX_ITEM_SET == rFmt.GetItemState(RES_BOX, true, &pItem) &&
    1399           0 :             (   ((SvxBoxItem*)pItem)->GetTop() ||
    1400           0 :                 ((SvxBoxItem*)pItem)->GetBottom()  ||
    1401           0 :                 ((SvxBoxItem*)pItem)->GetLeft()  ||
    1402           0 :                 ((SvxBoxItem*)pItem)->GetRight() );
    1403             : }
    1404             : 
    1405           0 : void WW8AttributeOutput::StartSection()
    1406             : {
    1407           0 :     m_rWW8Export.pO->clear();
    1408           0 : }
    1409             : 
    1410           0 : void WW8AttributeOutput::SectionFormProtection( bool bProtected )
    1411             : {
    1412             :     //If the document is to be exported as protected, then if a segment
    1413             :     //is not protected, set the unlocked flag
    1414           0 :     if ( m_rWW8Export.pSepx->DocumentIsProtected() && !bProtected )
    1415             :     {
    1416           0 :         if ( m_rWW8Export.bWrtWW8 )
    1417           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFProtected );
    1418             :         else
    1419           0 :             m_rWW8Export.pO->push_back( 139 );
    1420           0 :         m_rWW8Export.pO->push_back( 1 );
    1421             :     }
    1422           0 : }
    1423             : 
    1424           0 : void WW8AttributeOutput::SectionLineNumbering( sal_uLong nRestartNo, const SwLineNumberInfo& rLnNumInfo )
    1425             : {
    1426             :     // sprmSNLnnMod - activate Line Numbering and define Modulo
    1427           0 :     if ( m_rWW8Export.bWrtWW8 )
    1428           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SNLnnMod );
    1429             :     else
    1430           0 :         m_rWW8Export.pO->push_back( 154 );
    1431           0 :     SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (sal_uInt16)rLnNumInfo.GetCountBy() );
    1432             : 
    1433             :     // sprmSDxaLnn - xPosition of Line Number
    1434           0 :     if ( m_rWW8Export.bWrtWW8 )
    1435           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SDxaLnn );
    1436             :     else
    1437           0 :         m_rWW8Export.pO->push_back( 155 );
    1438           0 :     SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (sal_uInt16)rLnNumInfo.GetPosFromLeft() );
    1439             : 
    1440             :     // sprmSLnc - restart number: 0 per page, 1 per section, 2 never restart
    1441           0 :     if ( nRestartNo || !rLnNumInfo.IsRestartEachPage() )
    1442             :     {
    1443           0 :         if ( m_rWW8Export.bWrtWW8 )
    1444           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SLnc );
    1445             :         else
    1446           0 :             m_rWW8Export.pO->push_back( 152 );
    1447           0 :         m_rWW8Export.pO->push_back( nRestartNo ? 1 : 2 );
    1448             :     }
    1449             : 
    1450             :     // sprmSLnnMin - Restart the Line Number with given value
    1451           0 :     if ( nRestartNo )
    1452             :     {
    1453           0 :         if ( m_rWW8Export.bWrtWW8 )
    1454           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SLnnMin );
    1455             :         else
    1456           0 :             m_rWW8Export.pO->push_back( 160 );
    1457           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, (sal_uInt16)nRestartNo - 1 );
    1458             :     }
    1459           0 : }
    1460             : 
    1461           0 : void WW8AttributeOutput::SectionTitlePage()
    1462             : {
    1463             :     // sprmSFTitlePage
    1464           0 :     if ( m_rWW8Export.bWrtWW8 )
    1465           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFTitlePage );
    1466             :     else
    1467           0 :         m_rWW8Export.pO->push_back( 143 );
    1468           0 :     m_rWW8Export.pO->push_back( 1 );
    1469           0 : }
    1470             : 
    1471           0 : void WW8AttributeOutput::SectionPageBorders( const SwFrmFmt* pPdFmt, const SwFrmFmt* pPdFirstPgFmt )
    1472             : {
    1473           0 :     if ( m_rWW8Export.bWrtWW8 )              // write border of page
    1474             :     {
    1475           0 :         sal_uInt16 nPgBorder = MSWordSections::HasBorderItem( *pPdFmt ) ? 0 : USHRT_MAX;
    1476           0 :         if ( pPdFmt != pPdFirstPgFmt )
    1477             :         {
    1478           0 :             if ( MSWordSections::HasBorderItem( *pPdFirstPgFmt ) )
    1479             :             {
    1480           0 :                 if ( USHRT_MAX == nPgBorder )
    1481             :                 {
    1482           0 :                     nPgBorder = 1;
    1483             :                     // only the first page outlined -> Get the BoxItem from the correct format
    1484           0 :                     m_rWW8Export.pISet = &pPdFirstPgFmt->GetAttrSet();
    1485           0 :                     OutputItem( pPdFirstPgFmt->GetFmtAttr( RES_BOX ) );
    1486             :                 }
    1487             :             }
    1488           0 :             else if ( !nPgBorder )
    1489           0 :                 nPgBorder = 2;
    1490             :         }
    1491             : 
    1492           0 :         if ( USHRT_MAX != nPgBorder )
    1493             :         {
    1494             :             // write the Flag and Border Attribute
    1495           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SPgbProp );
    1496           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, nPgBorder );
    1497             :         }
    1498             :     }
    1499           0 : }
    1500             : 
    1501           0 : void WW8AttributeOutput::SectionBiDi( bool bBiDi )
    1502             : {
    1503           0 :     if ( m_rWW8Export.bWrtWW8 )
    1504             :     {
    1505           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFBiDi );
    1506           0 :         m_rWW8Export.pO->push_back( bBiDi? 1: 0 );
    1507             :     }
    1508           0 : }
    1509             : 
    1510           0 : void WW8AttributeOutput::SectionPageNumbering( sal_uInt16 nNumType, ::boost::optional<sal_uInt16> oPageRestartNumber )
    1511             : {
    1512             :     // sprmSNfcPgn
    1513           0 :     sal_uInt8 nb = WW8Export::GetNumId( nNumType );
    1514           0 :     if ( m_rWW8Export.bWrtWW8 )
    1515           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SNfcPgn );
    1516             :     else
    1517           0 :         m_rWW8Export.pO->push_back( 147 );
    1518           0 :     m_rWW8Export.pO->push_back( nb );
    1519             : 
    1520           0 :     if ( oPageRestartNumber )
    1521             :     {
    1522             :         // sprmSFPgnRestart
    1523           0 :         if ( m_rWW8Export.bWrtWW8 )
    1524           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SFPgnRestart );
    1525             :         else
    1526           0 :             m_rWW8Export.pO->push_back( 150 );
    1527           0 :         m_rWW8Export.pO->push_back( 1 );
    1528             : 
    1529             :         // sprmSPgnStart
    1530           0 :         if ( m_rWW8Export.bWrtWW8 )
    1531           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SPgnStart );
    1532             :         else
    1533           0 :             m_rWW8Export.pO->push_back( 161 );
    1534           0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, oPageRestartNumber.get() );
    1535             :     }
    1536           0 : }
    1537             : 
    1538           0 : void WW8AttributeOutput::SectionType( sal_uInt8 nBreakCode )
    1539             : {
    1540           0 :     if ( 2 != nBreakCode ) // new page is the default
    1541             :     {
    1542           0 :         if ( m_rWW8Export.bWrtWW8 )
    1543           0 :             SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SBkc );
    1544             :         else
    1545           0 :             m_rWW8Export.pO->push_back( 142 );
    1546           0 :         m_rWW8Export.pO->push_back( nBreakCode );
    1547             :     }
    1548           0 : }
    1549             : 
    1550           0 : void WW8AttributeOutput::SectionWW6HeaderFooterFlags( sal_uInt8 nHeadFootFlags )
    1551             : {
    1552           0 :     if ( nHeadFootFlags && !m_rWW8Export.bWrtWW8 )
    1553             :     {
    1554           0 :         sal_uInt8 nTmpFlags = nHeadFootFlags;
    1555           0 :         if ( m_rWW8Export.pDop->fFacingPages )
    1556             :         {
    1557           0 :             if ( !(nTmpFlags & WW8_FOOTER_EVEN) && (nTmpFlags & WW8_FOOTER_ODD ) )
    1558           0 :                 nTmpFlags |= WW8_FOOTER_EVEN;
    1559             : 
    1560           0 :             if ( !(nTmpFlags & WW8_HEADER_EVEN) && (nTmpFlags & WW8_HEADER_ODD ) )
    1561           0 :                 nTmpFlags |= WW8_HEADER_EVEN;
    1562             :         }
    1563             : 
    1564             :         // sprmSGprfIhdt, is only needed in WW95
    1565           0 :         m_rWW8Export.pO->push_back( 153 );
    1566           0 :         m_rWW8Export.pO->push_back( nTmpFlags );
    1567             :     }
    1568           0 : }
    1569             : 
    1570           0 : void WW8Export::SetupSectionPositions( WW8_PdAttrDesc* pA )
    1571             : {
    1572           0 :     if ( !pA )
    1573           0 :         return;
    1574             : 
    1575           0 :     if ( !pO->empty() ) // are there attributes ?
    1576             :     {
    1577           0 :         pA->m_nLen = pO->size();
    1578           0 :         pA->m_pData.reset(new sal_uInt8 [pO->size()]);
    1579             :         // store for later
    1580           0 :         memcpy( pA->m_pData.get(), pO->data(), pO->size() );
    1581           0 :         pO->clear(); // clear HdFt-Text
    1582             :     }
    1583             :     else // no attributes there
    1584             :     {
    1585           0 :         pA->m_pData.reset();
    1586           0 :         pA->m_nLen = 0;
    1587             :     }
    1588             : }
    1589             : 
    1590           0 : void WW8Export::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
    1591             :         const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt, sal_uInt8 nBreakCode )
    1592             : {
    1593           0 :     sal_uLong nCpPos = Fc2Cp( Strm().Tell() );
    1594             : 
    1595           0 :     IncrementHdFtIndex();
    1596           0 :     if ( !(nHeadFootFlags & WW8_HEADER_EVEN) && pDop->fFacingPages )
    1597           0 :         pSepx->OutHeaderFooter( *this, true, rFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
    1598             :     else
    1599           0 :         pSepx->OutHeaderFooter( *this, true, rLeftFmt, nCpPos, nHeadFootFlags, WW8_HEADER_EVEN, nBreakCode );
    1600           0 :     IncrementHdFtIndex();
    1601           0 :     pSepx->OutHeaderFooter( *this, true, rFmt, nCpPos, nHeadFootFlags, WW8_HEADER_ODD, nBreakCode );
    1602             : 
    1603           0 :     IncrementHdFtIndex();
    1604           0 :     if ( !(nHeadFootFlags & WW8_FOOTER_EVEN) && pDop->fFacingPages )
    1605           0 :         pSepx->OutHeaderFooter( *this, false, rFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
    1606             :     else
    1607           0 :         pSepx->OutHeaderFooter( *this, false, rLeftFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_EVEN, nBreakCode );
    1608           0 :     IncrementHdFtIndex();
    1609           0 :     pSepx->OutHeaderFooter( *this, false, rFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_ODD, nBreakCode );
    1610             : 
    1611             :     //#i24344# Drawing objects cannot be directly shared between main hd/ft
    1612             :     //and title hd/ft so we need to differenciate them
    1613           0 :     IncrementHdFtIndex();
    1614           0 :     pSepx->OutHeaderFooter( *this, true, rFirstPageFmt, nCpPos, nHeadFootFlags, WW8_HEADER_FIRST, nBreakCode );
    1615           0 :     pSepx->OutHeaderFooter( *this, false, rFirstPageFmt, nCpPos, nHeadFootFlags, WW8_FOOTER_FIRST, nBreakCode );
    1616           0 : }
    1617             : 
    1618           0 : void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAttrDesc* pA )
    1619             : {
    1620           0 :     const SwPageDesc* pPd = rSepInfo.pPageDesc;
    1621             : 
    1622           0 :     if ( rSepInfo.pSectionFmt && !pPd )
    1623           0 :         pPd = &pDoc->GetPageDesc( 0 );
    1624             : 
    1625           0 :     pAktPageDesc = pPd;
    1626             : 
    1627           0 :     if ( !pPd )
    1628           0 :         return;
    1629             : 
    1630           0 :     bool bOldPg = bOutPageDescs;
    1631           0 :     bOutPageDescs = true;
    1632             : 
    1633           0 :     AttrOutput().StartSection();
    1634             : 
    1635           0 :     AttrOutput().SectFootnoteEndnotePr();
    1636             : 
    1637             :     // forms
    1638           0 :     AttrOutput().SectionFormProtection( rSepInfo.IsProtected() );
    1639             : 
    1640             :     // line numbers
    1641           0 :     const SwLineNumberInfo& rLnNumInfo = pDoc->GetLineNumberInfo();
    1642           0 :     if ( rLnNumInfo.IsPaintLineNumbers() )
    1643           0 :         AttrOutput().SectionLineNumbering( rSepInfo.nLnNumRestartNo, rLnNumInfo );
    1644             : 
    1645             :     /*  sprmSBkc, break code:   0 No break, 1 New column
    1646             :         2 New page, 3 Even page, 4 Odd page
    1647             :         */
    1648           0 :     sal_uInt8 nBreakCode = 2;            // default neue Seite beginnen
    1649           0 :     bool bOutPgDscSet = true, bLeftRightPgChain = false, bOutputStyleItemSet = false;
    1650           0 :     const SwFrmFmt* pPdFmt = &pPd->GetMaster();
    1651           0 :     if ( rSepInfo.pSectionFmt )
    1652             :     {
    1653             :         // if pSectionFmt is set, then there is a SectionNode
    1654             :         //  valid pointer -> start Section ,
    1655             :         //  0xfff -> Section terminated
    1656           0 :         nBreakCode = 0;         // fortlaufender Abschnitt
    1657             : 
    1658           0 :         if ( rSepInfo.pPDNd && rSepInfo.pPDNd->IsCntntNode() )
    1659             :         {
    1660           0 :             if ( !NoPageBreakSection( &rSepInfo.pPDNd->GetCntntNode()->GetSwAttrSet() ) )
    1661             :             {
    1662           0 :                 nBreakCode = 2;
    1663             :             }
    1664             :         }
    1665             : 
    1666           0 :         if ( (SwSectionFmt*)0xFFFFFFFF != rSepInfo.pSectionFmt )
    1667             :         {
    1668           0 :             if ( nBreakCode == 0 )
    1669           0 :                 bOutPgDscSet = false;
    1670             : 
    1671             :             // produce Itemset, which inherits PgDesk-Attr-Set:
    1672             :             // als Nachkomme wird bei 'deep'-OutputItemSet
    1673             :             // auch der Vorfahr abgeklappert
    1674           0 :             const SfxItemSet* pPdSet = &pPdFmt->GetAttrSet();
    1675           0 :             SfxItemSet aSet( *pPdSet->GetPool(), pPdSet->GetRanges() );
    1676           0 :             aSet.SetParent( pPdSet );
    1677             : 
    1678             :             // am Nachkommen NUR  die Spaltigkeit gemaess Sect-Attr.
    1679             :             // umsetzen
    1680             : 
    1681             :             const SvxLRSpaceItem &rSectionLR =
    1682           0 :                 ItemGet<SvxLRSpaceItem>( *(rSepInfo.pSectionFmt), RES_LR_SPACE );
    1683             :             const SvxLRSpaceItem &rPageLR =
    1684           0 :                 ItemGet<SvxLRSpaceItem>( *pPdFmt, RES_LR_SPACE );
    1685             : 
    1686           0 :             SvxLRSpaceItem aResultLR( rPageLR.GetLeft() +
    1687           0 :                     rSectionLR.GetLeft(), rPageLR.GetRight() +
    1688           0 :                     rSectionLR.GetRight(), 0, 0, RES_LR_SPACE );
    1689             :             //i120133: The Section width should consider section indent value.
    1690           0 :             if (rSectionLR.GetLeft()+rSectionLR.GetRight()!=0)
    1691             :             {
    1692           0 :                 const SwFmtCol& rCol = dynamic_cast<const SwFmtCol&>(rSepInfo.pSectionFmt->GetFmtAttr(RES_COL));
    1693           0 :                 SwFmtCol aCol(rCol);
    1694           0 :                 aCol.SetAdjustValue(rSectionLR.GetLeft()+rSectionLR.GetRight());
    1695           0 :                 aSet.Put(aCol);
    1696             :             }
    1697             :             else
    1698           0 :                 aSet.Put(rSepInfo.pSectionFmt->GetFmtAttr(RES_COL));
    1699             : 
    1700           0 :             aSet.Put( aResultLR );
    1701             : 
    1702             :             // und raus damit ins WW-File
    1703           0 :             const SfxItemSet* pOldI = pISet;
    1704           0 :             pISet = &aSet;
    1705             : 
    1706             :             // Switch off test on default item values, if page description
    1707             :             // set (value of <bOutPgDscSet>) isn't written.
    1708           0 :             AttrOutput().OutputStyleItemSet( aSet, true, bOutPgDscSet );
    1709           0 :             bOutputStyleItemSet = true;
    1710             : 
    1711             :             //Cannot export as normal page framedir, as continuous sections
    1712             :             //cannot contain any grid settings like proper sections
    1713           0 :             AttrOutput().SectionBiDi( FRMDIR_HORI_RIGHT_TOP == TrueFrameDirection( *rSepInfo.pSectionFmt ) );
    1714             : 
    1715           0 :             pISet = pOldI;
    1716             :         }
    1717             :     }
    1718             : 
    1719             :     // Libreoffice 4.0 introduces support for page styles (SwPageDesc) with
    1720             :     // a different header/footer for the first page.  The same effect can be
    1721             :     // achieved by chaining two page styles together (SwPageDesc::GetFollow)
    1722             :     // which are identical except for header/footer.
    1723             :     // The latter method was previously used by the doc/docx import filter.
    1724             :     // In both of these cases, we emit a single Word section with different
    1725             :     // first page header/footer.
    1726           0 :     const SwFrmFmt* pPdFirstPgFmt = &pPd->GetFirstMaster();
    1727           0 :     bool titlePage = !pPd->IsFirstShared();
    1728           0 :     if ( bOutPgDscSet )
    1729             :     {
    1730             :         // if a Follow is set and it does not point to itself,
    1731             :         // then there is a page chain.
    1732             :         // Falls damit eine "Erste Seite" simuliert werden soll, so
    1733             :         // koennen wir das auch als solches schreiben.
    1734             :         // Anders sieht es mit Links/Rechts wechseln aus. Dafuer muss
    1735             :         // erkannt werden, wo der Seitenwechsel statt findet. Hier ist
    1736             :         // es aber dafuer zuspaet!
    1737           0 :         if ( pPd->GetFollow() && pPd != pPd->GetFollow() &&
    1738           0 :              pPd->GetFollow()->GetFollow() == pPd->GetFollow() &&
    1739           0 :              ( !rSepInfo.pPDNd || pPd->IsFollowNextPageOfNode( *rSepInfo.pPDNd ) ) )
    1740             :         {
    1741           0 :             const SwPageDesc *pFollow = pPd->GetFollow();
    1742           0 :             const SwFrmFmt& rFollowFmt = pFollow->GetMaster();
    1743           0 :             if ( sw::util::IsPlausableSingleWordSection( *pPdFirstPgFmt, rFollowFmt ) || titlePage )
    1744             :             {
    1745           0 :                 if (rSepInfo.pPDNd)
    1746           0 :                     pPdFirstPgFmt = pPd->GetPageFmtOfNode( *rSepInfo.pPDNd );
    1747             :                 else
    1748           0 :                     pPdFirstPgFmt = &pPd->GetMaster();
    1749             : 
    1750           0 :                 pAktPageDesc = pPd = pFollow;
    1751           0 :                 pPdFmt = &rFollowFmt;
    1752             : 
    1753             :                 // has different headers/footers for the title page
    1754           0 :                 titlePage = true;
    1755             :             }
    1756             :         }
    1757             : 
    1758           0 :         if( titlePage )
    1759           0 :             AttrOutput().SectionTitlePage();
    1760             : 
    1761           0 :         const SfxItemSet* pOldI = pISet;
    1762             : 
    1763             :         const SfxPoolItem* pItem;
    1764           0 :         if ( titlePage && SFX_ITEM_SET ==
    1765           0 :                 pPdFirstPgFmt->GetItemState( RES_PAPER_BIN, true, &pItem ) )
    1766             :         {
    1767           0 :             pISet = &pPdFirstPgFmt->GetAttrSet();
    1768           0 :             bOutFirstPage = true;
    1769           0 :             AttrOutput().OutputItem( *pItem );
    1770           0 :             bOutFirstPage = false;
    1771             :         }
    1772             : 
    1773             :         // left-/right chain of pagedescs ?
    1774           0 :         if ( pPd->GetFollow() && pPd != pPd->GetFollow() &&
    1775           0 :                 pPd->GetFollow()->GetFollow() == pPd &&
    1776           0 :                 (( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) &&
    1777           0 :                    nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) ||
    1778           0 :                  ( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) &&
    1779           0 :                    nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->GetFollow()->ReadUseOn() )) ))
    1780             :         {
    1781           0 :             bLeftRightPgChain = true;
    1782             : 
    1783             :             // which is the reference point? (left or right?)
    1784             :             // assume it is on the right side!
    1785           0 :             if ( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) )
    1786             :             {
    1787           0 :                 nBreakCode = 3;
    1788           0 :                 pPd = pPd->GetFollow();
    1789           0 :                 pPdFmt = &pPd->GetMaster();
    1790             :             }
    1791             :             else
    1792           0 :                 nBreakCode = 4;
    1793             :         }
    1794             : 
    1795           0 :         pISet = &pPdFmt->GetAttrSet();
    1796           0 :         if (!bOutputStyleItemSet)
    1797           0 :             AttrOutput().OutputStyleItemSet( pPdFmt->GetAttrSet(), true, false );
    1798           0 :         AttrOutput().SectionPageBorders( pPdFmt, pPdFirstPgFmt );
    1799           0 :         pISet = pOldI;
    1800             : 
    1801             :         // then the rest of the settings from PageDesc
    1802           0 :         AttrOutput().SectionPageNumbering( pPd->GetNumType().GetNumberingType(), rSepInfo.oPgRestartNo );
    1803             : 
    1804             :         // werden es nur linke oder nur rechte Seiten?
    1805           0 :         if ( 2 == nBreakCode )
    1806             :         {
    1807           0 :             if ( nsUseOnPage::PD_LEFT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) )
    1808           0 :                 nBreakCode = 3;
    1809           0 :             else if ( nsUseOnPage::PD_RIGHT == ( nsUseOnPage::PD_ALL & pPd->ReadUseOn() ) )
    1810           0 :                 nBreakCode = 4;
    1811             :         }
    1812             :     }
    1813             : 
    1814           0 :     AttrOutput().SectionType( nBreakCode );
    1815             : 
    1816           0 :     const SwTxtNode* pNd = rSepInfo.pNumNd;
    1817           0 :     if ( pNd )
    1818             :     {
    1819           0 :         const SwNumRule* pRule = pNd->GetNumRule();
    1820           0 :         if ( pRule )
    1821           0 :             OutputOlst( *pRule );
    1822             :     }
    1823             : 
    1824             :     // Header or Footer
    1825           0 :     sal_uInt8 nHeadFootFlags = 0;
    1826             : 
    1827             :     const SwFrmFmt* pPdLeftFmt = bLeftRightPgChain
    1828           0 :         ? &pPd->GetFollow()->GetMaster()
    1829           0 :         : &pPd->GetLeft();
    1830             : 
    1831           0 :     if ( nBreakCode != 0 )
    1832             :     {
    1833           0 :         if ( titlePage )
    1834             :         {
    1835             :             // there is a First Page:
    1836           0 :             MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_HEADER_FIRST );
    1837           0 :             MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFirstPgFmt, WW8_FOOTER_FIRST );
    1838             :         }
    1839           0 :         MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdFmt, WW8_HEADER_ODD );
    1840           0 :         MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdFmt, WW8_FOOTER_ODD );
    1841             : 
    1842           0 :         if ( !pPd->IsHeaderShared() || bLeftRightPgChain )
    1843           0 :             MSWordSections::SetHeaderFlag( nHeadFootFlags, *pPdLeftFmt, WW8_HEADER_EVEN );
    1844             : 
    1845           0 :         if ( !pPd->IsFooterShared() || bLeftRightPgChain )
    1846           0 :             MSWordSections::SetFooterFlag( nHeadFootFlags, *pPdLeftFmt, WW8_FOOTER_EVEN );
    1847           0 :         AttrOutput().SectionWW6HeaderFooterFlags( nHeadFootFlags );
    1848             :     }
    1849             : 
    1850             :     // binary filters only
    1851           0 :     SetupSectionPositions( pA );
    1852             : 
    1853             :     /*
    1854             :        !!!!!!!!!!!
    1855             :     // Umrandungen an Kopf- und Fusstexten muessten etwa so gehen:
    1856             :     // Dabei muss etwas wie pOut eingebaut werden,
    1857             :     // das bei jeder Spezialtext-Zeile wiederholt wird.
    1858             :     const SwFrmFmt* pFFmt = rFt.GetFooterFmt();
    1859             :     const SvxBoxItem& rBox = pFFmt->GetBox(false);
    1860             :     OutWW8_SwFmtBox1( m_rWW8Export.pOut, rBox, false);
    1861             :     !!!!!!!!!!!
    1862             :     You can turn this into paragraph attributes, which are then observed in each paragraph.
    1863             :     Applies to background / border.
    1864             :     !!!!!!!!!!!
    1865             :     */
    1866             : 
    1867           0 :     const SwTxtNode *pOldPageRoot = GetHdFtPageRoot();
    1868           0 :     SetHdFtPageRoot( rSepInfo.pPDNd ? rSepInfo.pPDNd->GetTxtNode() : 0 );
    1869             : 
    1870           0 :     WriteHeadersFooters( nHeadFootFlags, *pPdFmt, *pPdLeftFmt, *pPdFirstPgFmt, nBreakCode );
    1871             : 
    1872           0 :     SetHdFtPageRoot( pOldPageRoot );
    1873             : 
    1874           0 :     AttrOutput().EndSection();
    1875             : 
    1876             :     // outside of the section properties again
    1877           0 :     bOutPageDescs = bOldPg;
    1878             : }
    1879             : 
    1880           0 : bool WW8_WrPlcSepx::WriteKFTxt( WW8Export& rWrt )
    1881             : {
    1882           0 :     sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1883             : 
    1884             :     OSL_ENSURE( !pTxtPos, "who set the pointer?" );
    1885           0 :     pTxtPos = new WW8_WrPlc0( nCpStart );
    1886             : 
    1887           0 :     WriteFtnEndTxt( rWrt, nCpStart );
    1888           0 :     CheckForFacinPg( rWrt );
    1889             : 
    1890           0 :     unsigned int nOldIndex = rWrt.GetHdFtIndex();
    1891           0 :     rWrt.SetHdFtIndex( 0 );
    1892             : 
    1893           0 :     for ( sal_uInt16 i = 0; i < aSects.size(); ++i )
    1894             :     {
    1895           0 :         ::boost::shared_ptr<WW8_PdAttrDesc> const pAttrDesc(new WW8_PdAttrDesc);
    1896           0 :         m_SectionAttributes.push_back(pAttrDesc);
    1897             : 
    1898           0 :         WW8_SepInfo& rSepInfo = aSects[i];
    1899           0 :         rWrt.SectionProperties( rSepInfo, pAttrDesc.get() );
    1900             : 
    1901             :         // FIXME: this writes the section properties, but not of all sections;
    1902             :         // it's possible that later in the document (e.g. in endnotes) sections
    1903             :         // are added, but they won't have their properties written here!
    1904           0 :         m_bHeaderFooterWritten = true;
    1905           0 :     }
    1906           0 :     rWrt.SetHdFtIndex( nOldIndex ); //0
    1907             : 
    1908           0 :     if ( pTxtPos->Count() )
    1909             :     {
    1910             :         // HdFt available?
    1911           0 :         sal_uLong nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    1912           0 :         pTxtPos->Append( nCpEnd );  // End of last Header/Footer for PlcfHdd
    1913             : 
    1914           0 :         if ( nCpEnd > nCpStart )
    1915             :         {
    1916           0 :             ++nCpEnd;
    1917           0 :             pTxtPos->Append( nCpEnd + 1 );  // End of last Header/Footer for PlcfHdd
    1918             : 
    1919           0 :             rWrt.WriteStringAsPara( OUString() ); // CR ans Ende ( sonst mault WW )
    1920             :         }
    1921           0 :         rWrt.pFldHdFt->Finish( nCpEnd, rWrt.pFib->ccpText + rWrt.pFib->ccpFtn );
    1922           0 :         rWrt.pFib->ccpHdr = nCpEnd - nCpStart;
    1923             :     }
    1924             :     else
    1925           0 :         delete pTxtPos, pTxtPos = 0;
    1926             : 
    1927           0 :     return rWrt.pFib->ccpHdr != 0;
    1928             : }
    1929             : 
    1930           0 : void WW8_WrPlcSepx::WriteSepx( SvStream& rStrm ) const
    1931             : {
    1932             :     OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(aSects.size())
    1933             :         , "WriteSepx(): arrays out of sync!");
    1934           0 :     for (size_t i = 0; i < m_SectionAttributes.size(); i++) // all sections
    1935             :     {
    1936           0 :         WW8_PdAttrDesc *const pA = m_SectionAttributes[i].get();
    1937           0 :         if (pA->m_nLen && pA->m_pData != 0)
    1938             :         {
    1939             :             SVBT16 nL;
    1940           0 :             pA->m_nSepxFcPos = rStrm.Tell();
    1941           0 :             ShortToSVBT16( pA->m_nLen, nL );
    1942           0 :             rStrm.Write( nL, 2 );
    1943           0 :             rStrm.Write( pA->m_pData.get(), pA->m_nLen );
    1944             :         }
    1945             :     }
    1946           0 : }
    1947             : 
    1948           0 : void WW8_WrPlcSepx::WritePlcSed( WW8Export& rWrt ) const
    1949             : {
    1950             :     OSL_ENSURE(m_SectionAttributes.size() == static_cast<size_t>(aSects.size())
    1951             :         , "WritePlcSed(): arrays out of sync!");
    1952             :     OSL_ENSURE( aCps.size() == aSects.size() + 1, "WrPlcSepx: DeSync" );
    1953           0 :     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
    1954             : 
    1955             :     sal_uInt16 i;
    1956           0 :     for( i = 0; i <= aSects.size(); i++ )
    1957             :     {
    1958           0 :         sal_uInt32 nP = aCps[i];
    1959             :         SVBT32 nPos;
    1960           0 :         UInt32ToSVBT32( nP, nPos );
    1961           0 :         rWrt.pTableStrm->Write( nPos, 4 );
    1962             :     }
    1963             : 
    1964             :     static WW8_SED aSed = {{4, 0},{0, 0, 0, 0},{0, 0},{0xff, 0xff, 0xff, 0xff}};
    1965             : 
    1966           0 :     for (size_t j = 0; j < m_SectionAttributes.size(); j++ )
    1967             :     {
    1968             :         // Sepx-Pos
    1969           0 :         UInt32ToSVBT32( m_SectionAttributes[j]->m_nSepxFcPos, aSed.fcSepx );
    1970           0 :         rWrt.pTableStrm->Write( &aSed, sizeof( aSed ) );
    1971             :     }
    1972           0 :     rWrt.pFib->fcPlcfsed = nFcStart;
    1973           0 :     rWrt.pFib->lcbPlcfsed = rWrt.pTableStrm->Tell() - nFcStart;
    1974           0 : }
    1975             : 
    1976           0 : void WW8_WrPlcSepx::WritePlcHdd( WW8Export& rWrt ) const
    1977             : {
    1978             :     // Don't write out the PlcfHdd if ccpHdd is 0: it's a validation failure case.
    1979           0 :     if( rWrt.pFib->ccpHdr != 0 && pTxtPos && pTxtPos->Count() )
    1980             :     {
    1981           0 :         rWrt.pFib->fcPlcfhdd = rWrt.pTableStrm->Tell();
    1982           0 :         pTxtPos->Write( *rWrt.pTableStrm );             // Plc0
    1983           0 :         rWrt.pFib->lcbPlcfhdd = rWrt.pTableStrm->Tell() -
    1984           0 :                                 rWrt.pFib->fcPlcfhdd;
    1985             :     }
    1986           0 : }
    1987             : 
    1988           0 : void MSWordExportBase::WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader )
    1989             : {
    1990             :     const SwFmtCntnt *pCntnt;
    1991           0 :     if ( bHeader )
    1992             :     {
    1993           0 :         bHasHdr = true;
    1994           0 :         const SwFmtHeader& rHd = rFmt.GetHeader();
    1995             :         OSL_ENSURE( rHd.GetHeaderFmt(), "Header text is not here" );
    1996           0 :         pCntnt = &rHd.GetHeaderFmt()->GetCntnt();
    1997             :     }
    1998             :     else
    1999             :     {
    2000           0 :         bHasFtr = true;
    2001           0 :         const SwFmtFooter& rFt = rFmt.GetFooter();
    2002             :         OSL_ENSURE( rFt.GetFooterFmt(), "Footer text is not here" );
    2003           0 :         pCntnt = &rFt.GetFooterFmt()->GetCntnt();
    2004             :     }
    2005             : 
    2006           0 :     const SwNodeIndex* pSttIdx = pCntnt->GetCntntIdx();
    2007             : 
    2008           0 :     if ( pSttIdx )
    2009             :     {
    2010           0 :         SwNodeIndex aIdx( *pSttIdx, 1 ),
    2011           0 :         aEnd( *pSttIdx->GetNode().EndOfSectionNode() );
    2012           0 :         sal_uLong nStart = aIdx.GetIndex();
    2013           0 :         sal_uLong nEnd = aEnd.GetIndex();
    2014             : 
    2015             :         // Bereich also gueltiger Node
    2016           0 :         if ( nStart < nEnd )
    2017             :         {
    2018           0 :             bool bOldKF = bOutKF;
    2019           0 :             bOutKF = true;
    2020           0 :             WriteSpecialText( nStart, nEnd, TXT_HDFT );
    2021           0 :             bOutKF = bOldKF;
    2022             :         }
    2023             :         else
    2024           0 :             pSttIdx = 0;
    2025             :     }
    2026             : 
    2027           0 :     if ( !pSttIdx )
    2028             :     {
    2029             :         // there is no Header/Footer, but a CR is still necessary
    2030             :         OSL_ENSURE( pSttIdx, "Header/Footer text is not really present" );
    2031           0 :         AttrOutput().EmptyParagraph(); // CR ans Ende ( sonst mault WW )
    2032             :     }
    2033           0 : }
    2034             : 
    2035             : // class WW8_WrPlcFtnEdn : Collect the Footnotes and Endnotes and output their text
    2036             : // and Plcs at the end of the document.
    2037             : // WW8_WrPlcFtnEdn is the class for Footnotes and Endnotes
    2038             : 
    2039           0 : WW8_WrPlcSubDoc::WW8_WrPlcSubDoc()
    2040           0 :     : pTxtPos( 0 )
    2041             : {
    2042           0 : }
    2043             : 
    2044           0 : WW8_WrPlcSubDoc::~WW8_WrPlcSubDoc()
    2045             : {
    2046           0 :     delete pTxtPos;
    2047           0 : }
    2048             : 
    2049           0 : void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn )
    2050             : {
    2051           0 :     aCps.push_back( nCp );
    2052           0 :     aCntnt.push_back( &rFtn );
    2053           0 : }
    2054             : 
    2055           0 : WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd)
    2056             :     :
    2057             :         maDateTime( DateTime::EMPTY ),
    2058             :         m_nRangeStart(nRangeStart),
    2059           0 :         m_nRangeEnd(nRangeEnd)
    2060             : {
    2061           0 :     mpRichText = pPostIt->GetTextObject();
    2062           0 :     if (!mpRichText)
    2063           0 :         msSimpleText = pPostIt->GetTxt();
    2064           0 :     msOwner = pPostIt->GetPar1();
    2065           0 :     m_sInitials = pPostIt->GetInitials();
    2066           0 :     maDateTime = DateTime(pPostIt->GetDate(), pPostIt->GetTime());
    2067           0 : }
    2068             : 
    2069           0 : WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline)
    2070             :     :
    2071             :         mpRichText(0),
    2072             :         maDateTime( DateTime::EMPTY ),
    2073             :         m_nRangeStart(0),
    2074           0 :         m_nRangeEnd(0)
    2075             : {
    2076           0 :     msSimpleText = pRedline->GetComment();
    2077           0 :     msOwner = SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor());
    2078           0 :     maDateTime = pRedline->GetTimeStamp();
    2079           0 : }
    2080             : 
    2081           0 : void WW8_WrPlcAnnotations::AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp)
    2082             : {
    2083           0 :     m_aRangeStartPositions[rName] = nStartCp;
    2084           0 : }
    2085             : 
    2086           0 : void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt )
    2087             : {
    2088           0 :     aCps.push_back( nCp );
    2089             :     WW8_Annotation* p;
    2090           0 :     if( m_aRangeStartPositions.find(pPostIt->GetName()) != m_aRangeStartPositions.end() )
    2091             :     {
    2092           0 :         p = new WW8_Annotation(pPostIt, m_aRangeStartPositions[pPostIt->GetName()], nCp);
    2093           0 :         m_aRangeStartPositions.erase(pPostIt->GetName());
    2094             :     }
    2095             :     else
    2096             :     {
    2097           0 :         p = new WW8_Annotation(pPostIt, nCp, nCp);
    2098             :     }
    2099           0 :     aCntnt.push_back( p );
    2100           0 : }
    2101             : 
    2102           0 : void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwRedlineData *pRedline )
    2103             : {
    2104           0 :     maProcessedRedlines.insert(pRedline);
    2105           0 :     aCps.push_back( nCp );
    2106           0 :     WW8_Annotation* p = new WW8_Annotation(pRedline);
    2107           0 :     aCntnt.push_back( p );
    2108           0 : }
    2109             : 
    2110           0 : bool WW8_WrPlcAnnotations::IsNewRedlineComment( const SwRedlineData *pRedline )
    2111             : {
    2112           0 :     return maProcessedRedlines.find(pRedline) == maProcessedRedlines.end();
    2113             : }
    2114             : 
    2115           0 : WW8_WrPlcAnnotations::~WW8_WrPlcAnnotations()
    2116             : {
    2117           0 :     for( sal_uInt16 n=0; n < aCntnt.size(); n++ )
    2118           0 :         delete (WW8_Annotation*)aCntnt[n];
    2119           0 : }
    2120             : 
    2121           0 : bool WW8_WrPlcSubDoc::WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp,
    2122             :     WW8_CP& rCount )
    2123             : {
    2124           0 :     sal_uInt16 nLen = aCntnt.size();
    2125           0 :     if ( !nLen )
    2126           0 :         return false;
    2127             : 
    2128           0 :     sal_uLong nCpStart = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    2129           0 :     pTxtPos = new WW8_WrPlc0( nCpStart );
    2130             :     sal_uInt16 i;
    2131             : 
    2132           0 :     switch ( nTTyp )
    2133             :     {
    2134             :         case TXT_ATN:
    2135           0 :             for ( i = 0; i < nLen; i++ )
    2136             :             {
    2137             :                 // beginning for PlcfAtnTxt
    2138           0 :                 pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
    2139             : 
    2140           0 :                 rWrt.WritePostItBegin();
    2141           0 :                 const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
    2142           0 :                 if (rAtn.mpRichText)
    2143           0 :                     rWrt.WriteOutliner(*rAtn.mpRichText, nTTyp);
    2144             :                 else
    2145             :                 {
    2146           0 :                     OUString sTxt(rAtn.msSimpleText);
    2147           0 :                     rWrt.WriteStringAsPara(sTxt.replace(0x0A, 0x0B));
    2148             :                 }
    2149             :             }
    2150           0 :             break;
    2151             : 
    2152             :         case TXT_TXTBOX:
    2153             :         case TXT_HFTXTBOX:
    2154           0 :             for ( i = 0; i < nLen; i++ )
    2155             :             {
    2156             :                 // textbox content
    2157           0 :                 WW8_CP nCP = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    2158           0 :                 aCps.insert( aCps.begin()+i, nCP );
    2159           0 :                 pTxtPos->Append( nCP );
    2160             : 
    2161           0 :                 if( aCntnt[ i ] != NULL )
    2162             :                 {
    2163             :                 // is it an writer or sdr - textbox?
    2164           0 :                 const SdrObject& rObj = *(SdrObject*)aCntnt[ i ];
    2165           0 :                 if (rObj.GetObjInventor() == FmFormInventor)
    2166             :                 {
    2167           0 :                     sal_uInt8 nOldTyp = rWrt.nTxtTyp;
    2168           0 :                     rWrt.nTxtTyp = nTTyp;
    2169           0 :                     rWrt.GetOCXExp().ExportControl(rWrt,&rObj);
    2170           0 :                     rWrt.nTxtTyp = nOldTyp;
    2171             :                 }
    2172           0 :                 else if( rObj.ISA( SdrTextObj ) )
    2173           0 :                     rWrt.WriteSdrTextObj(rObj, nTTyp);
    2174             :                 else
    2175             :                 {
    2176           0 :                     const SwFrmFmt* pFmt = ::FindFrmFmt( &rObj );
    2177             :                     OSL_ENSURE( pFmt, "where is the format?" );
    2178             : 
    2179           0 :                     const SwNodeIndex* pNdIdx = pFmt->GetCntnt().GetCntntIdx();
    2180             :                     OSL_ENSURE( pNdIdx, "where is the StartNode of the Textbox?" );
    2181           0 :                     rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1,
    2182           0 :                                            pNdIdx->GetNode().EndOfSectionIndex(),
    2183           0 :                                            nTTyp );
    2184             :                     {
    2185           0 :                         SwNodeIndex aContentIdx = *pNdIdx;
    2186           0 :                         ++aContentIdx;
    2187           0 :                         if ( aContentIdx.GetNode().IsTableNode() )
    2188             :                         {
    2189           0 :                             bool bContainsOnlyTables = true;
    2190           0 :                             do {
    2191           0 :                                 aContentIdx = *(aContentIdx.GetNode().EndOfSectionNode());
    2192           0 :                                 ++aContentIdx;
    2193           0 :                                 if ( !aContentIdx.GetNode().IsTableNode() &&
    2194           0 :                                      aContentIdx.GetIndex() != pNdIdx->GetNode().EndOfSectionIndex() )
    2195             :                                 {
    2196           0 :                                     bContainsOnlyTables = false;
    2197             :                                 }
    2198           0 :                             } while ( aContentIdx.GetNode().IsTableNode() );
    2199           0 :                             if ( bContainsOnlyTables )
    2200             :                             {
    2201             :                                 // Additional paragraph containing a space to
    2202             :                                 // assure that by WW created RTF from written WW8
    2203             :                                 // does not crash WW.
    2204           0 :                                 rWrt.WriteStringAsPara( OUString(" ") );
    2205             :                             }
    2206           0 :                         }
    2207             :                     }
    2208             :                 }
    2209             :                 }
    2210           0 :                 else if( i < aSpareFmts.size() )
    2211             :                 {
    2212           0 :                     if( const SwFrmFmt* pFmt = (const SwFrmFmt*)aSpareFmts[ i ] )
    2213             :                     {
    2214           0 :                         const SwNodeIndex* pNdIdx = pFmt->GetCntnt().GetCntntIdx();
    2215           0 :                         rWrt.WriteSpecialText( pNdIdx->GetIndex() + 1,
    2216           0 :                                    pNdIdx->GetNode().EndOfSectionIndex(), nTTyp );
    2217             :                     }
    2218             :                 }
    2219             : 
    2220             :                 // CR at end of one textbox text ( otherwise WW gpft :-( )
    2221           0 :                 rWrt.WriteStringAsPara( OUString() );
    2222             :             }
    2223           0 :             break;
    2224             : 
    2225             :         case TXT_EDN:
    2226             :         case TXT_FTN:
    2227           0 :             for ( i = 0; i < nLen; i++ )
    2228             :             {
    2229             :                 // beginning for PlcfFtnTxt/PlcfEdnTxt
    2230           0 :                 pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
    2231             : 
    2232             :                 // Note content
    2233           0 :                 const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ];
    2234           0 :                 rWrt.WriteFtnBegin( *pFtn );
    2235           0 :                 const SwNodeIndex* pIdx = pFtn->GetTxtFtn()->GetStartNode();
    2236             :                 OSL_ENSURE( pIdx, "wo ist der StartNode der Fuss-/EndNote?" );
    2237           0 :                 rWrt.WriteSpecialText( pIdx->GetIndex() + 1,
    2238           0 :                                        pIdx->GetNode().EndOfSectionIndex(),
    2239           0 :                                        nTTyp );
    2240             :             }
    2241           0 :             break;
    2242             : 
    2243             :         default:
    2244             :             OSL_ENSURE( !this, "was ist das fuer ein SubDocType?" );
    2245             :     }
    2246             : 
    2247           0 :     pTxtPos->Append( rWrt.Fc2Cp( rWrt.Strm().Tell() ));
    2248             :     // CR ans Ende ( sonst mault WW )
    2249           0 :     rWrt.WriteStringAsPara( OUString() );
    2250             : 
    2251           0 :     WW8_CP nCpEnd = rWrt.Fc2Cp( rWrt.Strm().Tell() );
    2252           0 :     pTxtPos->Append( nCpEnd );
    2253           0 :     rCount = nCpEnd - nCpStart;
    2254             : 
    2255           0 :     return ( rCount != 0 );
    2256             : }
    2257             : 
    2258           0 : static bool lcl_AuthorComp( const std::pair<OUString,OUString>& aFirst, const std::pair<OUString,OUString>& aSecond)
    2259             : {
    2260           0 :     return aFirst.first < aSecond.first;
    2261             : }
    2262             : 
    2263           0 : static bool lcl_PosComp( const std::pair<WW8_CP, int>& aFirst, const std::pair<WW8_CP, int>& aSecond)
    2264             : {
    2265           0 :     return aFirst.first < aSecond.first;
    2266             : }
    2267             : 
    2268           0 : void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp,
    2269             :     WW8_FC& rTxtStart, sal_Int32& rTxtCount, WW8_FC& rRefStart, sal_Int32& rRefCount ) const
    2270             : {
    2271             : 
    2272           0 :     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
    2273           0 :     sal_uInt16 nLen = aCps.size();
    2274           0 :     if ( !nLen )
    2275           0 :         return;
    2276             : 
    2277             :     OSL_ENSURE( aCps.size() + 2 == pTxtPos->Count(), "WritePlc: DeSync" );
    2278             : 
    2279           0 :     ::std::vector<std::pair<OUString,OUString> > aStrArr;
    2280             :     typedef ::std::vector<std::pair<OUString,OUString> >::iterator myiter;
    2281           0 :     WW8Fib& rFib = *rWrt.pFib;              // n+1-te CP-Pos nach Handbuch
    2282             :     sal_uInt16 i;
    2283           0 :     bool bWriteCP = true;
    2284             : 
    2285           0 :     switch ( nTTyp )
    2286             :     {
    2287             :         case TXT_ATN:
    2288             :             {
    2289           0 :                 std::vector< std::pair<WW8_CP, int> > aRangeStartPos; // The second of the pair is the original index before sorting.
    2290           0 :                 std::vector< std::pair<WW8_CP, int> > aRangeEndPos; // Same, so we can map between the indexes before/after sorting.
    2291           0 :                 std::map<int, int> aAtnStartMap; // Maps from annotation index to start index.
    2292           0 :                 std::map<int, int> aStartEndMap; // Maps from start index to end index.
    2293             :                 // then write first the GrpXstAtnOwners
    2294           0 :                 for ( i = 0; i < nLen; ++i )
    2295             :                 {
    2296           0 :                     const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
    2297           0 :                     aStrArr.push_back(std::pair<OUString,OUString>(rAtn.msOwner,rAtn.m_sInitials));
    2298           0 :                     if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
    2299             :                     {
    2300           0 :                         aRangeStartPos.push_back(std::make_pair(rAtn.m_nRangeStart, i));
    2301           0 :                         aRangeEndPos.push_back(std::make_pair(rAtn.m_nRangeEnd, i));
    2302             :                     }
    2303             :                 }
    2304             : 
    2305             :                 //sort and remove duplicates
    2306           0 :                 ::std::sort(aStrArr.begin(), aStrArr.end(),&lcl_AuthorComp);
    2307           0 :                 myiter aIter = ::std::unique(aStrArr.begin(), aStrArr.end());
    2308           0 :                 aStrArr.erase(aIter, aStrArr.end());
    2309             : 
    2310             :                 // Also sort the start and end positions. We need to reference
    2311             :                 // the start index in the annotation table and also need to
    2312             :                 // reference the end index in the start table, so build a map
    2313             :                 // that knows what index to reference, after sorting.
    2314           0 :                 std::sort(aRangeStartPos.begin(), aRangeStartPos.end(), &lcl_PosComp);
    2315           0 :                 for (i = 0; i < aRangeStartPos.size(); ++i)
    2316           0 :                     aAtnStartMap[aRangeStartPos[i].second] = i;
    2317           0 :                 std::sort(aRangeEndPos.begin(), aRangeEndPos.end(), &lcl_PosComp);
    2318           0 :                 for (i = 0; i < aRangeEndPos.size(); ++i)
    2319           0 :                     aStartEndMap[aRangeEndPos[ aAtnStartMap[i] ].second] = i;
    2320             : 
    2321           0 :                 if ( rWrt.bWrtWW8 )
    2322             :                 {
    2323           0 :                     for ( i = 0; i < aStrArr.size(); ++i )
    2324             :                     {
    2325           0 :                         const OUString& sAuthor = aStrArr[i].first;
    2326           0 :                         SwWW8Writer::WriteShort(*rWrt.pTableStrm, sAuthor.getLength());
    2327             :                         SwWW8Writer::WriteString16(*rWrt.pTableStrm, sAuthor,
    2328           0 :                                 false);
    2329             :                     }
    2330             :                 }
    2331             :                 else
    2332             :                 {
    2333           0 :                     for ( i = 0; i < aStrArr.size(); ++i )
    2334             :                     {
    2335           0 :                         const OUString& sAuthor = aStrArr[i].first;
    2336           0 :                         rWrt.pTableStrm->WriteUChar( (sal_uInt8)sAuthor.getLength() );
    2337             :                         SwWW8Writer::WriteString8(*rWrt.pTableStrm, sAuthor, false,
    2338           0 :                                 RTL_TEXTENCODING_MS_1252);
    2339             :                     }
    2340             :                 }
    2341             : 
    2342           0 :                 rFib.fcGrpStAtnOwners = nFcStart;
    2343           0 :                 nFcStart = rWrt.pTableStrm->Tell();
    2344           0 :                 rFib.lcbGrpStAtnOwners = nFcStart - rFib.fcGrpStAtnOwners;
    2345             : 
    2346             :                 // Commented text ranges
    2347           0 :                 if ( rWrt.bWrtWW8 )
    2348             :                 {
    2349           0 :                     if( aRangeStartPos.size() > 0 )
    2350             :                     {
    2351             :                         // Commented text ranges starting positions (Plcfbkf.aCP)
    2352           0 :                         rFib.fcPlcfAtnbkf = nFcStart;
    2353           0 :                         for ( i = 0; i < aRangeStartPos.size(); ++i )
    2354             :                         {
    2355           0 :                             SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i].first );
    2356             :                         }
    2357           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i-1].first + 1);
    2358             : 
    2359             :                         // Commented text ranges additional informations (Plcfbkf.aFBKF)
    2360           0 :                         for ( i = 0; i < aRangeStartPos.size(); ++i )
    2361             :                         {
    2362           0 :                             SwWW8Writer::WriteShort( *rWrt.pTableStrm, aStartEndMap[i] ); // FBKF.ibkl
    2363           0 :                             SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc
    2364             :                         }
    2365             : 
    2366           0 :                         nFcStart = rWrt.pTableStrm->Tell();
    2367           0 :                         rFib.lcbPlcfAtnbkf = nFcStart - rFib.fcPlcfAtnbkf;
    2368             : 
    2369             :                         // Commented text ranges ending positions (PlcfBkl.aCP)
    2370           0 :                         rFib.fcPlcfAtnbkl = nFcStart;
    2371           0 :                         for ( i = 0; i < aRangeEndPos.size(); ++i )
    2372             :                         {
    2373           0 :                             SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i].first );
    2374             :                         }
    2375           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i-1].first + 1);
    2376             : 
    2377           0 :                         nFcStart = rWrt.pTableStrm->Tell();
    2378           0 :                         rFib.lcbPlcfAtnbkl = nFcStart - rFib.fcPlcfAtnbkl;
    2379             : 
    2380             :                         // Commented text ranges as bookmarks (SttbfAtnBkmk)
    2381           0 :                         rFib.fcSttbfAtnbkmk = nFcStart;
    2382           0 :                         SwWW8Writer::WriteShort( *rWrt.pTableStrm, (sal_Int16)(sal_uInt16)0xFFFF ); // SttbfAtnBkmk.fExtend
    2383           0 :                         SwWW8Writer::WriteShort( *rWrt.pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData
    2384           0 :                         SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xA );                   // SttbfAtnBkmk.cbExtra
    2385             : 
    2386           0 :                         for ( i = 0; i < aRangeStartPos.size(); ++i )
    2387             :                         {
    2388           0 :                             SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );         // SttbfAtnBkmk.cchData
    2389             :                             // One ATNBE structure for all text ranges
    2390           0 :                             SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x0100 );    // ATNBE.bmc
    2391           0 :                             SwWW8Writer::WriteLong( *rWrt.pTableStrm, aAtnStartMap[i] );          // ATNBE.lTag
    2392           0 :                             SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );         // ATNBE.lTagOld
    2393             :                         }
    2394             : 
    2395           0 :                         nFcStart = rWrt.pTableStrm->Tell();
    2396           0 :                         rFib.lcbSttbfAtnbkmk = nFcStart - rFib.fcSttbfAtnbkmk;
    2397             :                     }
    2398             :                 }
    2399             : 
    2400             :                 // Write the extended >= Word XP ATLD records
    2401           0 :                 if( rWrt.bWrtWW8 )
    2402             :                 {
    2403           0 :                     for( i = 0; i < nLen; ++i )
    2404             :                     {
    2405           0 :                         const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
    2406             : 
    2407           0 :                         sal_uInt32 nDTTM = sw::ms::DateTime2DTTM(rAtn.maDateTime);
    2408             : 
    2409           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, nDTTM );
    2410           0 :                         SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
    2411           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
    2412           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
    2413           0 :                         SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
    2414             :                     }
    2415             : 
    2416           0 :                     rFib.fcAtrdExtra = nFcStart;
    2417           0 :                     nFcStart = rWrt.pTableStrm->Tell();
    2418           0 :                     rFib.lcbAtrdExtra = nFcStart - rFib.fcAtrdExtra;
    2419           0 :                     rFib.fcHplxsdr = 0x01010002;  //WTF, but apparently necessary
    2420           0 :                     rFib.lcbHplxsdr = 0;
    2421           0 :                 }
    2422             :             }
    2423           0 :             break;
    2424             :         case TXT_TXTBOX:
    2425             :         case TXT_HFTXTBOX:
    2426             :             {
    2427           0 :                 pTxtPos->Write( *rWrt.pTableStrm );
    2428           0 :                 const std::vector<sal_uInt32>* pShapeIds = GetShapeIdArr();
    2429             :                 OSL_ENSURE( pShapeIds, "Where are the ShapeIds?" );
    2430             : 
    2431           0 :                 for ( i = 0; i < nLen; ++i )
    2432             :                 {
    2433             :                     // write textbox story - FTXBXS
    2434             :                     // is it an writer or sdr - textbox?
    2435           0 :                     const SdrObject* pObj = (SdrObject*)aCntnt[ i ];
    2436           0 :                     sal_Int32 nCnt = 1;
    2437           0 :                     if (pObj && !pObj->ISA( SdrTextObj ) )
    2438             :                     {
    2439             :                         // find the "highest" SdrObject of this
    2440           0 :                         const SwFrmFmt& rFmt = *::FindFrmFmt( pObj );
    2441             : 
    2442           0 :                         const SwFmtChain* pChn = &rFmt.GetChain();
    2443           0 :                         while ( pChn->GetNext() )
    2444             :                         {
    2445             :                             // has a chain?
    2446             :                             // then calc the cur pos in the chain
    2447           0 :                             ++nCnt;
    2448           0 :                             pChn = &pChn->GetNext()->GetChain();
    2449             :                         }
    2450             :                     }
    2451           0 :                     if( NULL == pObj )
    2452             :                     {
    2453           0 :                         if( i < aSpareFmts.size() && aSpareFmts[ i ] )
    2454             :                         {
    2455           0 :                             const SwFrmFmt& rFmt = *(const SwFrmFmt*)aSpareFmts[ i ];
    2456             : 
    2457           0 :                             const SwFmtChain* pChn = &rFmt.GetChain();
    2458           0 :                             while( pChn->GetNext() )
    2459             :                             {
    2460             :                                 // has a chain?
    2461             :                                 // then calc the cur pos in the chain
    2462           0 :                                 ++nCnt;
    2463           0 :                                 pChn = &pChn->GetNext()->GetChain();
    2464             :                             }
    2465             :                         }
    2466             :                     }
    2467             :                     // long cTxbx / iNextReuse
    2468           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, nCnt );
    2469             :                     // long cReusable
    2470           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
    2471             :                     // short fReusable
    2472           0 :                     SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
    2473             :                     // long reserved
    2474           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
    2475             :                     // long lid
    2476             :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm,
    2477           0 :                             (*pShapeIds)[i]);
    2478             :                     // long txidUndo
    2479           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );
    2480             :                 }
    2481           0 :                 SwWW8Writer::FillCount( *rWrt.pTableStrm, 22 );
    2482           0 :                 bWriteCP = false;
    2483             :             }
    2484           0 :             break;
    2485             :     }
    2486             : 
    2487           0 :     if ( bWriteCP )
    2488             :     {
    2489             :         // write CP Positions
    2490           0 :         for ( i = 0; i < nLen; i++ )
    2491           0 :             SwWW8Writer::WriteLong( *rWrt.pTableStrm, aCps[ i ] );
    2492             : 
    2493             :         // n+1-te CP-Pos nach Handbuch
    2494             :         SwWW8Writer::WriteLong( *rWrt.pTableStrm,
    2495           0 :                 rFib.ccpText + rFib.ccpFtn + rFib.ccpHdr + rFib.ccpEdn +
    2496           0 :                 rFib.ccpTxbx + rFib.ccpHdrTxbx + 1 );
    2497             : 
    2498           0 :         if ( TXT_ATN == nTTyp )
    2499             :         {
    2500           0 :             sal_uInt16 nlTag = 0;
    2501           0 :             for ( i = 0; i < nLen; ++i )
    2502             :             {
    2503           0 :                 const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i];
    2504             : 
    2505             :                 //aStrArr is sorted
    2506             :                 myiter aIter = ::std::lower_bound(aStrArr.begin(),
    2507             :                         aStrArr.end(), std::pair<OUString,OUString>(rAtn.msOwner,OUString()),
    2508           0 :                         &lcl_AuthorComp);
    2509             :                 OSL_ENSURE(aIter != aStrArr.end() && aIter->first == rAtn.msOwner,
    2510             :                         "Impossible");
    2511           0 :                 sal_uInt16 nFndPos = static_cast< sal_uInt16 >(aIter - aStrArr.begin());
    2512           0 :                 OUString sInitials( aIter->second );
    2513           0 :                 sal_uInt8 nInitialsLen = (sal_uInt8)sInitials.getLength();
    2514           0 :                 if ( nInitialsLen > 9 )
    2515             :                 {
    2516           0 :                     sInitials = sInitials.copy( 0, 9 );
    2517           0 :                     nInitialsLen = 9;
    2518             :                 }
    2519             : 
    2520             :                 // xstUsrInitl[ 10 ] pascal-style String holding initials
    2521             :                 // of annotation author
    2522           0 :                 if ( rWrt.bWrtWW8 )
    2523             :                 {
    2524           0 :                     SwWW8Writer::WriteShort(*rWrt.pTableStrm, nInitialsLen);
    2525             :                     SwWW8Writer::WriteString16(*rWrt.pTableStrm, sInitials,
    2526           0 :                             false);
    2527             :                     SwWW8Writer::FillCount( *rWrt.pTableStrm,
    2528           0 :                             (9 - nInitialsLen) * 2 );
    2529             : 
    2530             :                 }
    2531             :                 else
    2532             :                 {
    2533           0 :                     rWrt.pTableStrm->WriteUChar( nInitialsLen );
    2534             :                     SwWW8Writer::WriteString8(*rWrt.pTableStrm, sInitials,
    2535           0 :                             false, RTL_TEXTENCODING_MS_1252);
    2536           0 :                     SwWW8Writer::FillCount(*rWrt.pTableStrm, 9 - nInitialsLen);
    2537             :                 }
    2538             : 
    2539             :                 // documents layout of WriteShort's below:
    2540             : 
    2541             :                 // SVBT16 ibst;      // index into GrpXstAtnOwners
    2542             :                 // SVBT16 ak;        // not used
    2543             :                 // SVBT16 grfbmc;    // not used
    2544             :                 // SVBT32 ITagBkmk;  // when not -1, this tag identifies the
    2545             : 
    2546           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos );
    2547           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
    2548           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
    2549           0 :                 if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd )
    2550             :                 {
    2551           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag );
    2552           0 :                     ++nlTag;
    2553             :                 }
    2554             :                 else
    2555           0 :                     SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 );
    2556           0 :             }
    2557             :         }
    2558             :         else
    2559             :         {
    2560           0 :             sal_uInt16 nNo = 0;
    2561           0 :             for ( i = 0; i < nLen; ++i )             // write Flags
    2562             :             {
    2563           0 :                 const SwFmtFtn* pFtn = (SwFmtFtn*)aCntnt[ i ];
    2564             :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm,
    2565           0 :                         !pFtn->GetNumStr().isEmpty() ? 0 : ++nNo );
    2566             :             }
    2567             :         }
    2568             :     }
    2569           0 :     rRefStart = nFcStart;
    2570           0 :     nFcStart = rWrt.pTableStrm->Tell();
    2571           0 :     rRefCount = nFcStart - rRefStart;
    2572             : 
    2573           0 :     pTxtPos->Write( *rWrt.pTableStrm );
    2574             : 
    2575           0 :     switch ( nTTyp )
    2576             :     {
    2577             :         case TXT_TXTBOX:
    2578             :         case TXT_HFTXTBOX:
    2579           0 :             for ( i = 0; i < nLen; ++i )
    2580             :             {
    2581             :                 // write break descriptor (BKD)
    2582             :                 // short itxbxs
    2583           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, i );
    2584             :                 // short dcpDepend
    2585           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 );
    2586             :                 // short flags : icol/fTableBreak/fColumnBreak/fMarked/
    2587             :                 //               fUnk/fTextOverflow
    2588           0 :                 SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x800 );
    2589             :             }
    2590           0 :             SwWW8Writer::FillCount( *rWrt.pTableStrm, 6 );
    2591           0 :             break;
    2592             :     }
    2593             : 
    2594           0 :     rTxtStart = nFcStart;
    2595           0 :     rTxtCount = rWrt.pTableStrm->Tell() - nFcStart;
    2596             : }
    2597             : 
    2598           0 : const std::vector<sal_uInt32>* WW8_WrPlcSubDoc::GetShapeIdArr() const
    2599             : {
    2600           0 :     return 0;
    2601           0 : }
    2602             : 
    2603             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10