LCOV - code coverage report
Current view: top level - libreoffice/sw/source/filter/ww8 - ww8atr.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1049 2573 40.8 %
Date: 2012-12-17 Functions: 89 140 63.6 %
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             : 
      21             : /*
      22             :  * This file contains methods for the WW8 output
      23             :  * (nodes, attributes, formats und chars).
      24             :  */
      25             : 
      26             : #include <hintids.hxx>
      27             : 
      28             : #include <vcl/svapp.hxx>
      29             : #include <vcl/salbtype.hxx>
      30             : #include <svl/zformat.hxx>
      31             : #include <svl/itemiter.hxx>
      32             : #include <svl/whiter.hxx>
      33             : #include <editeng/fontitem.hxx>
      34             : #include <editeng/tstpitem.hxx>
      35             : #include <editeng/adjitem.hxx>
      36             : #include <editeng/spltitem.hxx>
      37             : #include <editeng/widwitem.hxx>
      38             : #include <editeng/lspcitem.hxx>
      39             : #include <editeng/keepitem.hxx>
      40             : #include <editeng/shaditem.hxx>
      41             : #include <editeng/brshitem.hxx>
      42             : #include <editeng/postitem.hxx>
      43             : #include <editeng/wghtitem.hxx>
      44             : #include <editeng/kernitem.hxx>
      45             : #include <editeng/crsditem.hxx>
      46             : #include <editeng/cmapitem.hxx>
      47             : #include <editeng/wrlmitem.hxx>
      48             : #include <editeng/udlnitem.hxx>
      49             : #include <editeng/langitem.hxx>
      50             : #include <editeng/escpitem.hxx>
      51             : #include <editeng/fhgtitem.hxx>
      52             : #include <editeng/colritem.hxx>
      53             : #include <editeng/hyznitem.hxx>
      54             : #include <editeng/brkitem.hxx>
      55             : #include <editeng/lrspitem.hxx>
      56             : #include <editeng/ulspitem.hxx>
      57             : #include <editeng/boxitem.hxx>
      58             : #include <editeng/cntritem.hxx>
      59             : #include <editeng/shdditem.hxx>
      60             : #include <editeng/akrnitem.hxx>
      61             : #include <editeng/pbinitem.hxx>
      62             : #include <editeng/emphitem.hxx>
      63             : #include <editeng/twolinesitem.hxx>
      64             : #include <editeng/charscaleitem.hxx>
      65             : #include <editeng/charrotateitem.hxx>
      66             : #include <editeng/charreliefitem.hxx>
      67             : #include <editeng/paravertalignitem.hxx>
      68             : #include <editeng/pgrditem.hxx>
      69             : #include <editeng/frmdiritem.hxx>
      70             : #include <editeng/blnkitem.hxx>
      71             : #include <editeng/charhiddenitem.hxx>
      72             : #include <editeng/paperinf.hxx>
      73             : #include <fmtfld.hxx>
      74             : #include <fchrfmt.hxx>
      75             : #include <fmtfsize.hxx>
      76             : #include <fmtpdsc.hxx>
      77             : #include <fmtornt.hxx>
      78             : #include <fmtanchr.hxx>
      79             : #include <fmtclds.hxx>
      80             : #include <fmtsrnd.hxx>
      81             : #include <fmtftn.hxx>
      82             : #include <fmtflcnt.hxx>
      83             : #include <frmatr.hxx>
      84             : #include <swtable.hxx>
      85             : #include <fmtinfmt.hxx>
      86             : #include <txtfld.hxx>
      87             : #include <txtftn.hxx>
      88             : #include <poolfmt.hxx>
      89             : #include <doc.hxx>          // Doc for footnotes
      90             : #include <docary.hxx>
      91             : #include <pam.hxx>
      92             : #include <paratr.hxx>
      93             : #include <fldbas.hxx>       // for SwField
      94             : #include <docufld.hxx>      // for SwField
      95             : #include <expfld.hxx>
      96             : #include <pagedesc.hxx>     // for SwPageDesc
      97             : #include <flddat.hxx>       // for Date fields
      98             : #include <ndtxt.hxx>        // for Numrules
      99             : #include <swrect.hxx>
     100             : #include <reffld.hxx>
     101             : #include <ftninfo.hxx>
     102             : #include <charfmt.hxx>
     103             : #include <section.hxx>
     104             : #include <lineinfo.hxx>
     105             : #include <fmtline.hxx>
     106             : #include <tox.hxx>
     107             : #include <fmtftntx.hxx>
     108             : #include <breakit.hxx>
     109             : #include <com/sun/star/i18n/ScriptType.hpp>
     110             : #include <unotools/localedatawrapper.hxx>
     111             : #include <tgrditem.hxx>
     112             : #include <flddropdown.hxx>
     113             : #include <chpfld.hxx>
     114             : #include <fmthdft.hxx>
     115             : 
     116             : #include <writerfilter/doctok/sprmids.hxx>
     117             : 
     118             : #include <fmtcntnt.hxx>
     119             : #include "writerhelper.hxx"
     120             : #include "writerwordglue.hxx"
     121             : #include "wrtww8.hxx"
     122             : #include "ww8par.hxx"
     123             : #include "ww8attributeoutput.hxx"
     124             : #include "fields.hxx"
     125             : #include <vcl/outdev.hxx>
     126             : #include <i18npool/languagetag.hxx>
     127             : 
     128             : using ::editeng::SvxBorderLine;
     129             : using namespace ::com::sun::star;
     130             : using namespace nsFieldFlags;
     131             : using namespace nsSwDocInfoSubType;
     132             : 
     133             : /*
     134             :  * um nicht immer wieder nach einem Update festzustellen, das irgendwelche
     135             :  * Hint-Ids dazugekommen sind, wird hier definiert, die Groesse der Tabelle
     136             :  * definiert und mit der akt. verglichen. Bei unterschieden wird der
     137             :  * Compiler schon meckern.
     138             :  *
     139             :  * diese Section und die dazugeherigen Tabellen muessen in folgenden Files
     140             :  * gepflegt werden: rtf\rtfatr.cxx, sw6\sw6atr.cxx, w4w\w4watr.cxx
     141             : */
     142             : 
     143             : #if !defined(MSC) && !defined(UNX) && !defined(PPC) && !defined(__MINGW32__)
     144             : 
     145             : #define ATTRFNTAB_SIZE 130
     146             : #if ATTRFNTAB_SIZE != POOLATTR_END - POOLATTR_BEGIN
     147             : #   error "Attribut-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
     148             : #endif
     149             : 
     150             : #define NODETAB_SIZE 3
     151             : #if NODETAB_SIZE != RES_NODE_END - RES_NODE_BEGIN
     152             : #   error "Node-Tabelle ist ungueltigt. Wurden neue Hint-ID's zugefuegt ??"
     153             : #endif
     154             : 
     155             : #endif
     156             : 
     157             : using namespace sw::util;
     158             : using namespace sw::types;
     159             : 
     160         552 : bool WW8Export::CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich )
     161             : {
     162         552 :     bool bRet = true;
     163         552 :     if ( nScript == i18n::ScriptType::ASIAN )
     164             :     {
     165             :         //for asian in ww8, there is only one fontsize
     166             :         //and one fontstyle (posture/weight) for ww6
     167             :         //there is the additional problem that there
     168             :         //is only one font setting for all three scripts
     169           0 :         switch ( nWhich )
     170             :         {
     171             :             case RES_CHRATR_FONTSIZE:
     172             :             case RES_CHRATR_POSTURE:
     173             :             case RES_CHRATR_WEIGHT:
     174           0 :                 bRet = false;
     175           0 :                 break;
     176             :             case RES_CHRATR_LANGUAGE:
     177             :             case RES_CHRATR_CTL_FONT:
     178             :             case RES_CHRATR_CTL_FONTSIZE:
     179             :             case RES_CHRATR_CTL_LANGUAGE:
     180             :             case RES_CHRATR_CTL_POSTURE:
     181             :             case RES_CHRATR_CTL_WEIGHT:
     182           0 :                 if (bWrtWW8 == 0)
     183           0 :                     bRet = false;
     184             :             default:
     185           0 :                 break;
     186             :         }
     187             :     }
     188         552 :     else if ( nScript == i18n::ScriptType::COMPLEX )
     189             :     {
     190             :         //Complex is ok in ww8, but for ww6 there is only
     191             :         //one font, one fontsize, one fontsize (weight/posture)
     192             :         //and only one language
     193           0 :         if ( bWrtWW8 == 0 )
     194             :         {
     195           0 :             switch ( nWhich )
     196             :             {
     197             :                 case RES_CHRATR_CJK_FONT:
     198             :                 case RES_CHRATR_CJK_FONTSIZE:
     199             :                 case RES_CHRATR_CJK_POSTURE:
     200             :                 case RES_CHRATR_CJK_WEIGHT:
     201             :                 case RES_CHRATR_CJK_LANGUAGE:
     202             :                 case RES_CHRATR_FONT:
     203             :                 case RES_CHRATR_FONTSIZE:
     204             :                 case RES_CHRATR_POSTURE:
     205             :                 case RES_CHRATR_WEIGHT:
     206             :                 case RES_CHRATR_LANGUAGE:
     207           0 :                     bRet = false;
     208           0 :                     break;
     209             :                 default:
     210           0 :                     break;
     211             :             }
     212             :         }
     213             :     }
     214             :     else
     215             :     {
     216             :         //for western in ww8, there is only one fontsize
     217             :         //and one fontstyle (posture/weight) for ww6
     218             :         //there is the additional problem that there
     219             :         //is only one font setting for all three scripts
     220         552 :         switch ( nWhich )
     221             :         {
     222             :             case RES_CHRATR_CJK_FONTSIZE:
     223             :             case RES_CHRATR_CJK_POSTURE:
     224             :             case RES_CHRATR_CJK_WEIGHT:
     225         116 :                 bRet = false;
     226         116 :                 break;
     227             :             case RES_CHRATR_CJK_LANGUAGE:
     228             :             case RES_CHRATR_CTL_FONT:
     229             :             case RES_CHRATR_CTL_FONTSIZE:
     230             :             case RES_CHRATR_CTL_LANGUAGE:
     231             :             case RES_CHRATR_CTL_POSTURE:
     232             :             case RES_CHRATR_CTL_WEIGHT:
     233         170 :                 if ( bWrtWW8 == 0 )
     234           0 :                     bRet = false;
     235             :             default:
     236         436 :                 break;
     237             :         }
     238             :     }
     239         552 :     return bRet;
     240             : }
     241             : 
     242             : //------------------------------------------------------------
     243             : //  Hilfsroutinen fuer Styles
     244             : //------------------------------------------------------------
     245             : 
     246        1086 : void MSWordExportBase::ExportPoolItemsToCHP( sw::PoolItems &rItems, sal_uInt16 nScript )
     247             : {
     248        1086 :     sw::cPoolItemIter aEnd = rItems.end();
     249        5914 :     for ( sw::cPoolItemIter aI = rItems.begin(); aI != aEnd; ++aI )
     250             :     {
     251        4828 :         const SfxPoolItem *pItem = aI->second;
     252        4828 :         sal_uInt16 nWhich = pItem->Which();
     253        4828 :         if ( ( isCHRATR( nWhich ) || isTXTATR( nWhich ) ) && CollapseScriptsforWordOk( nScript, nWhich ) )
     254             :         {
     255        2810 :             AttrOutput().OutputItem( *pItem );
     256             :         }
     257             :     }
     258        1086 : }
     259             : 
     260             : /*
     261             :  * Format wie folgt ausgeben:
     262             :  *      - gebe die Attribute aus; ohne Parents!
     263             :  */
     264             : 
     265        1954 : void MSWordExportBase::OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, sal_uInt16 nScript,
     266             :                                       bool bExportParentItemSet )
     267             : {
     268        1954 :     if( bExportParentItemSet || rSet.Count() )
     269             :     {
     270             :         const SfxPoolItem* pItem;
     271        1866 :         pISet = &rSet;                  // fuer Doppel-Attribute
     272             : 
     273             :         // If frame dir is set, but not adjust, then force adjust as well
     274        1866 :         if ( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_FRAMEDIR, bExportParentItemSet ) )
     275             :         {
     276             :             // No explicit adjust set ?
     277         172 :             if ( SFX_ITEM_SET != rSet.GetItemState( RES_PARATR_ADJUST, bExportParentItemSet ) )
     278             :             {
     279         168 :                 if ( 0 != ( pItem = rSet.GetItem( RES_PARATR_ADJUST, bExportParentItemSet ) ) )
     280             :                 {
     281             :                     // then set the adjust used by the parent format
     282           0 :                     AttrOutput().OutputItem( *pItem );
     283             :                 }
     284             :             }
     285             :         }
     286             : 
     287        1866 :         if ( bPapFmt && SFX_ITEM_SET == rSet.GetItemState( RES_PARATR_NUMRULE, bExportParentItemSet, &pItem ) )
     288             :         {
     289           6 :             AttrOutput().OutputItem( *pItem );
     290             : 
     291             :             // switch off the numerbering?
     292           6 :             if ( !( (SwNumRuleItem*)pItem )->GetValue().Len() &&
     293           0 :                  SFX_ITEM_SET != rSet.GetItemState( RES_LR_SPACE, false) &&
     294           0 :                  SFX_ITEM_SET == rSet.GetItemState( RES_LR_SPACE, true, &pItem ) )
     295             :             {
     296             :                 // the set the LR-Space of the parentformat!
     297           0 :                 AttrOutput().OutputItem( *pItem );
     298             :             }
     299             :         }
     300             : 
     301        1866 :         sw::PoolItems aItems;
     302        1866 :         GetPoolItems( rSet, aItems, bExportParentItemSet );
     303        1866 :         if ( bChpFmt )
     304         770 :             ExportPoolItemsToCHP(aItems, nScript);
     305             : 
     306        1866 :         if ( bPapFmt )
     307             :         {
     308        1096 :             sw::cPoolItemIter aEnd = aItems.end();
     309        7144 :             for ( sw::cPoolItemIter aI = aItems.begin(); aI != aEnd; ++aI )
     310             :             {
     311        6048 :                 pItem = aI->second;
     312        6048 :                 sal_uInt16 nWhich = pItem->Which();
     313        6048 :                 if ( nWhich >= RES_PARATR_BEGIN && nWhich < RES_FRMATR_END && nWhich != RES_PARATR_NUMRULE)
     314        2868 :                     AttrOutput().OutputItem( *pItem );
     315             :             }
     316             :         }
     317        1866 :         pISet = 0;                      // fuer Doppel-Attribute
     318             :     }
     319        1954 : }
     320             : #include "switerator.hxx"
     321         112 : void MSWordExportBase::GatherChapterFields()
     322             : {
     323             :     //If the header/footer contains a chapter field
     324         112 :     SwFieldType* pType = pDoc->GetSysFldType( RES_CHAPTERFLD );
     325         112 :     SwIterator<SwFmtFld,SwFieldType> aFmtFlds( *pType );
     326         112 :     for ( SwFmtFld* pFld = aFmtFlds.First(); pFld; pFld = aFmtFlds.Next() )
     327             :     {
     328           0 :         if (const SwTxtFld *pTxtFld = pFld->GetTxtFld())
     329             :         {
     330           0 :             const SwTxtNode &rTxtNode = pTxtFld->GetTxtNode();
     331           0 :             maChapterFieldLocs.push_back(rTxtNode.GetIndex());
     332             :         }
     333         112 :     }
     334         112 : }
     335             : 
     336           0 : bool MSWordExportBase::CntntContainsChapterField(const SwFmtCntnt &rCntnt) const
     337             : {
     338           0 :     bool bRet = false;
     339           0 :     if ( const SwNodeIndex* pSttIdx = rCntnt.GetCntntIdx() )
     340             :     {
     341           0 :         SwNodeIndex aIdx( *pSttIdx, 1 );
     342           0 :         SwNodeIndex aEnd( *pSttIdx->GetNode().EndOfSectionNode() );
     343           0 :         sal_uLong nStart = aIdx.GetIndex();
     344           0 :         sal_uLong nEnd = aEnd.GetIndex();
     345             :         //If the header/footer contains a chapter field
     346           0 :         mycCFIter aIEnd = maChapterFieldLocs.end();
     347           0 :         for ( mycCFIter aI = maChapterFieldLocs.begin(); aI != aIEnd; ++aI )
     348             :         {
     349           0 :             if ( ( nStart <= *aI ) && ( *aI <= nEnd ) )
     350             :             {
     351           0 :                 bRet = true;
     352           0 :                 break;
     353             :             }
     354           0 :         }
     355             :     }
     356           0 :     return bRet;
     357             : }
     358             : 
     359           4 : bool MSWordExportBase::FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const
     360             : {
     361           4 :     if ( maChapterFieldLocs.empty() )
     362           4 :         return false;
     363             : 
     364           0 :     const SwFrmFmt *pFmt = 0;
     365             : 
     366           0 :     pFmt = rFmt.GetHeader().GetHeaderFmt();
     367           0 :     if ( pFmt && CntntContainsChapterField( pFmt->GetCntnt() ) )
     368           0 :         return true;
     369             : 
     370           0 :     pFmt = rFmt.GetFooter().GetFooterFmt();
     371           0 :     if ( pFmt && CntntContainsChapterField( pFmt->GetCntnt() ) )
     372           0 :         return true;
     373             : 
     374           0 :     return false;
     375             : }
     376             : 
     377           8 : bool MSWordExportBase::SetAktPageDescFromNode(const SwNode &rNd)
     378             : {
     379           8 :     bool bNewPageDesc = false;
     380           8 :     const SwPageDesc* pCurrent = SwPageDesc::GetPageDescOfNode(rNd);
     381             :     OSL_ENSURE(pCurrent && pAktPageDesc, "Not possible surely");
     382           8 :     if (pAktPageDesc && pCurrent)
     383             :     {
     384           8 :         if (pCurrent != pAktPageDesc)
     385             :         {
     386           4 :             if (pAktPageDesc->GetFollow() != pCurrent)
     387           0 :                 bNewPageDesc = true;
     388             :             else
     389             :             {
     390           4 :                 const SwFrmFmt& rTitleFmt = pAktPageDesc->GetMaster();
     391           4 :                 const SwFrmFmt& rFollowFmt = pCurrent->GetMaster();
     392             : 
     393             :                 bNewPageDesc = !IsPlausableSingleWordSection(rTitleFmt,
     394           4 :                     rFollowFmt);
     395             :             }
     396           4 :             pAktPageDesc = pCurrent;
     397             :         }
     398             :         else
     399             :         {
     400           4 :             const SwFrmFmt &rFmt = pCurrent->GetMaster();
     401           4 :             bNewPageDesc = FmtHdFtContainsChapterField(rFmt);
     402             :         }
     403             :     }
     404           8 :     return bNewPageDesc;
     405             : }
     406             : 
     407             : // Da WW nur Break-After ( Pagebreak und Sectionbreaks ) kennt, im SW aber
     408             : // Bagebreaks "vor" und "nach" und Pagedescs nur "vor" existieren, werden
     409             : // die Breaks 2* durchgeklimpert, naemlich vor und hinter jeder Zeile.
     410             : // Je nach BreakTyp werden sie vor oder nach der Zeile gesetzt.
     411             : // Es duerfen nur Funktionen gerufen werden, die nicht in den
     412             : // Ausgabebereich pO schreiben, da dieser nur einmal fuer CHP und PAP existiert
     413             : // und damit im falschen landen wuerden.
     414         212 : void MSWordExportBase::OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd )
     415             : {
     416         212 :     if ( bStyDef || bOutKF || bInWriteEscher || bOutPageDescs )
     417         212 :         return;
     418             : 
     419         180 :     bBreakBefore = true;
     420             : 
     421         180 :     bool bNewPageDesc = false;
     422         180 :     const SfxPoolItem* pItem=0;
     423         180 :     const SwFmtPageDesc *pPgDesc=0;
     424             : 
     425             :     //Output a sectionbreak if theres a new pagedesciptor.  otherwise output a
     426             :     //pagebreak if there is a pagebreak here, unless the new page (follow
     427             :     //style) is different to the current one, in which case plump for a
     428             :     //section.
     429         180 :     bool bBreakSet = false;
     430             : 
     431         180 :     if ( pSet && pSet->Count() )
     432             :     {
     433          90 :         if ( SFX_ITEM_SET == pSet->GetItemState( RES_PAGEDESC, false, &pItem ) &&
     434           8 :              dynamic_cast<const SwFmtPageDesc*>(pItem)->GetRegisteredIn() != NULL)
     435             :         {
     436           8 :             bBreakSet = true;
     437           8 :             bNewPageDesc = true;
     438           8 :             pPgDesc = (const SwFmtPageDesc*)pItem;
     439           8 :             pAktPageDesc = pPgDesc->GetPageDesc();
     440             :         }
     441          74 :         else if ( SFX_ITEM_SET == pSet->GetItemState( RES_BREAK, false, &pItem ) )
     442             :         {
     443             :             // Word does not like hard break attributes in some table cells
     444           8 :             bool bRemoveHardBreakInsideTable = false;
     445           8 :             if ( bOutTable )
     446             :             {
     447           0 :                 const SwTableNode* pTableNode = rNd.FindTableNode();
     448           0 :                 if ( pTableNode )
     449             :                 {
     450           0 :                     const SwTableBox* pBox = rNd.GetTblBox();
     451           0 :                     const SwTableLine* pLine = pBox ? pBox->GetUpper() : 0;
     452             :                     // but only for non-complex tables
     453           0 :                     if ( pLine && !pLine->GetUpper() )
     454             :                     {
     455             :                         // check if box is not first in that line:
     456           0 :                         if ( 0 < pLine->GetTabBoxes().GetPos( pBox ) && pBox->GetSttNd() )
     457             :                         {
     458           0 :                             bRemoveHardBreakInsideTable = true;
     459             :                         }
     460             :                     }
     461             :                 }
     462             :             }
     463             : 
     464           8 :             bBreakSet = true;
     465             : 
     466           8 :             if ( !bRemoveHardBreakInsideTable )
     467             :             {
     468             :                 OSL_ENSURE(pAktPageDesc, "should not be possible");
     469             :                 /*
     470             :                  If because of this pagebreak the page desc following the page
     471             :                  break is the follow style of the current page desc then output a
     472             :                  section break using that style instead.  At least in those cases
     473             :                  we end up with the same style in word and writer, nothing can be
     474             :                  done when it happens when we get a new pagedesc because we
     475             :                  overflow from the first page style.
     476             :                 */
     477           8 :                 if ( pAktPageDesc )
     478             :                 {
     479             :                     // #i76301# - assure that there is a page break before set at the node.
     480           8 :                     const SvxFmtBreakItem* pBreak = dynamic_cast<const SvxFmtBreakItem*>(pItem);
     481          16 :                     if ( pBreak &&
     482           8 :                          pBreak->GetBreak() == SVX_BREAK_PAGE_BEFORE )
     483             :                     {
     484           8 :                         bNewPageDesc = SetAktPageDescFromNode( rNd );
     485             :                     }
     486             :                 }
     487           8 :                 if ( !bNewPageDesc )
     488           8 :                     AttrOutput().OutputItem( *pItem );
     489             :             }
     490             :         }
     491             :     }
     492             : 
     493             :     /*
     494             :     #i9301#
     495             :     No explicit page break, lets see if the style had one and we've moved to a
     496             :     new page style because of it, if we have to then we take the opportunity to
     497             :     set the equivalent word section here. We *could* do it for every paragraph
     498             :     that moves onto a new page because of layout, but that would be insane.
     499             :     */
     500         180 :     bool bHackInBreak = false;
     501         180 :     if ( !bBreakSet )
     502             :     {
     503         164 :         if ( const SwCntntNode *pNd = rNd.GetCntntNode() )
     504             :         {
     505             :             const SvxFmtBreakItem &rBreak =
     506         144 :                 ItemGet<SvxFmtBreakItem>( *pNd, RES_BREAK );
     507         144 :             if ( rBreak.GetBreak() == SVX_BREAK_PAGE_BEFORE )
     508           0 :                 bHackInBreak = true;
     509             :             else
     510             :             {   // Even a pagedesc item is set, the break item can be set 'NONE',
     511             :                 // but a pagedesc item is an implicit page break before...
     512             :                 const SwFmtPageDesc &rPageDesc =
     513         144 :                     ItemGet<SwFmtPageDesc>( *pNd, RES_PAGEDESC );
     514         144 :                 if ( rPageDesc.KnowsPageDesc() )
     515           0 :                     bHackInBreak = true;
     516             :             }
     517             :         }
     518             :     }
     519             : 
     520         180 :     if ( bHackInBreak )
     521             :     {
     522             :         OSL_ENSURE( pAktPageDesc, "should not be possible" );
     523           0 :         if ( pAktPageDesc )
     524           0 :             bNewPageDesc = SetAktPageDescFromNode( rNd );
     525             :     }
     526             : 
     527         180 :     if ( bNewPageDesc && pAktPageDesc )
     528             :     {
     529           8 :         PrepareNewPageDesc( pSet, rNd, pPgDesc, pAktPageDesc );
     530             :     }
     531         180 :     bBreakBefore = false;
     532             : }
     533             : 
     534             : // #i76300#
     535           0 : bool MSWordExportBase::OutputFollowPageDesc( const SfxItemSet* pSet, const SwTxtNode* pNd )
     536             : {
     537           0 :     bool bRet = false;
     538             : 
     539           0 :     if ( pNd &&
     540             :          pAktPageDesc &&
     541           0 :          pAktPageDesc != pAktPageDesc->GetFollow() )
     542             :     {
     543           0 :         PrepareNewPageDesc( pSet, *pNd, 0, pAktPageDesc->GetFollow() );
     544           0 :         bRet = true;
     545             :     }
     546             : 
     547           0 :     return bRet;
     548             : }
     549             : 
     550           4 : const SwSectionFmt* MSWordExportBase::GetSectionFormat( const SwNode& rNd ) const
     551             : {
     552           4 :     const SwSectionFmt* pFmt = NULL;
     553           4 :     const SwSectionNode* pSect = rNd.FindSectionNode();
     554           4 :     if ( pSect &&
     555           0 :          CONTENT_SECTION == pSect->GetSection().GetType() )
     556             :     {
     557           0 :         pFmt = pSect->GetSection().GetFmt();
     558             :     }
     559             : 
     560           4 :     return pFmt;
     561             : }
     562             : 
     563           4 : sal_uLong MSWordExportBase::GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const
     564             : {
     565           4 :     const SwFmtLineNumber* pNItem = 0;
     566           4 :     if ( pSet )
     567             :     {
     568           4 :         pNItem = &( ItemGet<SwFmtLineNumber>( *pSet, RES_LINENUMBER ) );
     569             :     }
     570           0 :     else if ( const SwCntntNode *pNd = rNd.GetCntntNode() )
     571             :     {
     572           0 :         pNItem = &( ItemGet<SwFmtLineNumber>( *pNd, RES_LINENUMBER ) );
     573             :     }
     574             : 
     575           4 :     return pNItem? pNItem->GetStartValue() : 0;
     576             : }
     577             : 
     578           6 : void WW8Export::PrepareNewPageDesc( const SfxItemSet*pSet,
     579             :                                       const SwNode& rNd,
     580             :                                       const SwFmtPageDesc* pNewPgDescFmt,
     581             :                                       const SwPageDesc* pNewPgDesc )
     582             : {
     583             :     // Die PageDescs werden beim Auftreten von PageDesc-Attributen nur in
     584             :     // WW8Writer::pSepx mit der entsprechenden Position eingetragen.  Das
     585             :     // Aufbauen und die Ausgabe der am PageDesc haengenden Attribute und
     586             :     // Kopf/Fusszeilen passiert nach dem Haupttext und seinen Attributen.
     587             : 
     588           6 :     sal_uLong nFcPos = ReplaceCr( msword::PageBreak ); // Page/Section-Break
     589             : 
     590             :     // tatsaechlich wird hier NOCH NICHTS ausgegeben, sondern
     591             :     // nur die Merk-Arrays aCps, aSects entsprechend ergaenzt
     592           6 :     if ( !nFcPos )
     593          10 :         return;
     594             : 
     595           2 :     const SwSectionFmt* pFmt = GetSectionFormat( rNd );
     596           2 :     const sal_uLong nLnNm = GetSectionLineNo( pSet, rNd );
     597             : 
     598             :     OSL_ENSURE( pNewPgDescFmt || pNewPgDesc, "Neither page desc format nor page desc provided." );
     599             : 
     600           2 :     if ( pNewPgDescFmt )
     601             :     {
     602           2 :         pSepx->AppendSep( Fc2Cp( nFcPos ), *pNewPgDescFmt, rNd, pFmt, nLnNm );
     603             :     }
     604           0 :     else if ( pNewPgDesc )
     605             :     {
     606           0 :         pSepx->AppendSep( Fc2Cp( nFcPos ), pNewPgDesc, rNd, pFmt, nLnNm );
     607             :     }
     608             : }
     609             : 
     610           0 : void MSWordExportBase::CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft )
     611             : {
     612             :     const SvxTabStopItem *pItem =
     613           0 :         sw::util::HasItem<SvxTabStopItem>( rSet, RES_PARATR_TABSTOP );
     614             : 
     615           0 :     if ( pItem )
     616             :     {
     617             :         // dann muss das fuer die Ausgabe korrigiert werden
     618           0 :         SvxTabStopItem aTStop(*pItem);
     619           0 :         for ( sal_uInt16 nCnt = 0; nCnt < aTStop.Count(); ++nCnt )
     620             :         {
     621           0 :             SvxTabStop& rTab = (SvxTabStop&)aTStop[ nCnt ];
     622           0 :             if ( SVX_TAB_ADJUST_DEFAULT != rTab.GetAdjustment() &&
     623           0 :                 rTab.GetTabPos() >= nAbsLeft )
     624             :             {
     625           0 :                 rTab.GetTabPos() -= nAbsLeft;
     626             :             }
     627             :             else
     628             :             {
     629           0 :                 aTStop.Remove( nCnt );
     630           0 :                 --nCnt;
     631             :             }
     632             :         }
     633           0 :         rSet.Put( aTStop );
     634             :     }
     635           0 : }
     636             : 
     637          44 : sal_uInt8 WW8Export::GetNumId( sal_uInt16 eNumType )
     638             : {
     639          44 :     sal_uInt8 nRet = 0;
     640          44 :     switch( eNumType )
     641             :     {
     642             :     case SVX_NUM_CHARS_UPPER_LETTER:
     643           0 :     case SVX_NUM_CHARS_UPPER_LETTER_N:  nRet = 3;       break;
     644             :     case SVX_NUM_CHARS_LOWER_LETTER:
     645           0 :     case SVX_NUM_CHARS_LOWER_LETTER_N:  nRet = 4;       break;
     646           0 :     case SVX_NUM_ROMAN_UPPER:           nRet = 1;       break;
     647           8 :     case SVX_NUM_ROMAN_LOWER:           nRet = 2;       break;
     648             : 
     649             :     case SVX_NUM_BITMAP:
     650           0 :     case SVX_NUM_CHAR_SPECIAL:          nRet = 23;      break;
     651             : 
     652             :     // nix, macht WW undokumentiert auch so
     653          18 :     case SVX_NUM_NUMBER_NONE:           nRet = 0xff;    break;
     654             :     }
     655          44 :     return nRet;
     656             : }
     657             : 
     658           6 : void WW8AttributeOutput::OutlineNumbering( sal_uInt8 nLvl, const SwNumFmt &rNFmt, const SwFmt &rFmt )
     659             : {
     660           6 :     if ( nLvl >= WW8ListManager::nMaxLevel )
     661           0 :         nLvl = WW8ListManager::nMaxLevel-1;
     662             : 
     663           6 :     if ( m_rWW8Export.bWrtWW8 )
     664             :     {
     665             :         // write sprmPOutLvl sprmPIlvl and sprmPIlfo
     666           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_POutLvl );
     667           6 :         m_rWW8Export.pO->push_back( nLvl );
     668           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl );
     669           6 :         m_rWW8Export.pO->push_back( nLvl );
     670           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo );
     671             :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO,
     672           6 :                 1 + m_rWW8Export.GetId( *m_rWW8Export.pDoc->GetOutlineNumRule() ) );
     673             :     }
     674             :     else
     675             :     {
     676           0 :         m_rWW8Export.Out_SwNumLvl( nLvl );
     677           0 :         if ( rNFmt.GetPositionAndSpaceMode() ==
     678             :                                    SvxNumberFormat::LABEL_WIDTH_AND_POSITION  &&
     679           0 :              rNFmt.GetAbsLSpace() )
     680             :         {
     681           0 :             SwNumFmt aNumFmt( rNFmt );
     682             :             const SvxLRSpaceItem& rLR =
     683           0 :                 ItemGet<SvxLRSpaceItem>( rFmt, RES_LR_SPACE );
     684             : 
     685             :             aNumFmt.SetAbsLSpace( writer_cast<short>(
     686           0 :                     aNumFmt.GetAbsLSpace() + rLR.GetLeft() ) );
     687             :             m_rWW8Export.Out_NumRuleAnld(
     688           0 :                     *m_rWW8Export.pDoc->GetOutlineNumRule(),
     689           0 :                     aNumFmt, nLvl );
     690             :         }
     691             :         else
     692             :             m_rWW8Export.Out_NumRuleAnld(
     693           0 :                     *m_rWW8Export.pDoc->GetOutlineNumRule(),
     694           0 :                     rNFmt, nLvl );
     695             :     }
     696           6 : }
     697             : 
     698             : // #i77805#
     699          96 : bool WW8Export::DisallowInheritingOutlineNumbering(const SwFmt &rFmt)
     700             : {
     701          96 :     bool bRet( false );
     702             : 
     703             :     //If there is no numbering on this fmt, but its parent was outline
     704             :     //numbered, then in writer this is no inheritied, but in word it would
     705             :     //be, so we must export "no numbering" and "body level" to make word
     706             :     //behave like writer (see #i25755)
     707          96 :     if (SFX_ITEM_SET != rFmt.GetItemState(RES_PARATR_NUMRULE, false))
     708             :     {
     709          96 :         if (const SwFmt *pParent = rFmt.DerivedFrom())
     710             :         {
     711          96 :             if (((const SwTxtFmtColl*)pParent)->IsAssignedToListLevelOfOutlineStyle())
     712             :             {
     713           0 :                 if (bWrtWW8)
     714             :                 {
     715           0 :                     SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_POutLvl);
     716           0 :                     pO->push_back(sal_uInt8(9));
     717           0 :                     SwWW8Writer::InsUInt16(*pO, NS_sprm::LN_PIlfo);
     718           0 :                     SwWW8Writer::InsUInt16(*pO, 0);
     719             : 
     720           0 :                     bRet = true;
     721             :                 }
     722             :                 /*whats the winword 6 way to do this ?*/
     723             :             }
     724             :         }
     725             :     }
     726             : 
     727          96 :     return bRet;
     728             : }
     729             : 
     730        1718 : void MSWordExportBase::OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt )
     731             : {
     732        1718 :     bool bCallOutSet = true;
     733        1718 :     const SwModify* pOldMod = pOutFmtNode;
     734        1718 :     pOutFmtNode = &rFmt;
     735             : 
     736        1718 :     switch( rFmt.Which() )
     737             :     {
     738             :     case RES_CONDTXTFMTCOLL:
     739             :     case RES_TXTFMTCOLL:
     740        1480 :         if( bPapFmt )
     741             :         {
     742         740 :             if (((const SwTxtFmtColl&)rFmt).IsAssignedToListLevelOfOutlineStyle())
     743             :             {
     744           6 :                 int nLvl = ((const SwTxtFmtColl&)rFmt).GetAssignedOutlineStyleLevel();
     745             : 
     746             :                 //if outline numbered
     747             :                 // if Write StyleDefinition then write the OutlineRule
     748           6 :                 const SwNumFmt& rNFmt = pDoc->GetOutlineNumRule()->Get( static_cast<sal_uInt16>( nLvl ) );
     749           6 :                 if ( bStyDef )
     750           6 :                     AttrOutput().OutlineNumbering( static_cast< sal_uInt8 >( nLvl ), rNFmt, rFmt );
     751             : 
     752           6 :                 if ( rNFmt.GetPositionAndSpaceMode() ==
     753             :                                            SvxNumberFormat::LABEL_WIDTH_AND_POSITION  &&
     754           0 :                      rNFmt.GetAbsLSpace() )
     755             :                 {
     756           0 :                     SfxItemSet aSet( rFmt.GetAttrSet() );
     757             :                     SvxLRSpaceItem aLR(
     758           0 :                         ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
     759             : 
     760           0 :                     aLR.SetTxtLeft( aLR.GetTxtLeft() + rNFmt.GetAbsLSpace() );
     761           0 :                     aLR.SetTxtFirstLineOfst( GetWordFirstLineOffset(rNFmt));
     762             : 
     763           0 :                     aSet.Put( aLR );
     764           0 :                     CorrectTabStopInSet( aSet, rNFmt.GetAbsLSpace() );
     765             :                     OutputItemSet( aSet, bPapFmt, bChpFmt,
     766           0 :                         i18n::ScriptType::LATIN, mbExportModeRTF);
     767           0 :                     bCallOutSet = false;
     768             :                 }
     769             :             }
     770             :             else
     771             :             {
     772             :                 //otherwise we might have to remove outline numbering from
     773             :                 //what gets exported if the parent style was outline numbered
     774             :                 // #i77805#
     775             :                 // If inherited outline numbering is suppress, the left/right
     776             :                 // margins has to be exported explicitly.
     777         734 :                 if ( bStyDef && DisallowInheritingOutlineNumbering(rFmt) )
     778             :                 {
     779           0 :                     SfxItemSet aSet( rFmt.GetAttrSet() );
     780             :                     SvxLRSpaceItem aLR(
     781           0 :                         ItemGet<SvxLRSpaceItem>(aSet, RES_LR_SPACE));
     782           0 :                     aSet.Put( aLR );
     783             :                     OutputItemSet( aSet, bPapFmt, bChpFmt,
     784           0 :                         com::sun::star::i18n::ScriptType::LATIN, mbExportModeRTF);
     785           0 :                     bCallOutSet = false;
     786             :                 }
     787             :             }
     788             :         }
     789        1480 :         break;
     790             : 
     791             :     case RES_CHRFMT:
     792         104 :         break;
     793             :     case RES_FLYFRMFMT:
     794          12 :         if (bFlyFmt)
     795             :         {
     796             :             OSL_ENSURE(mpParentFrame, "No parent frame, all broken");
     797             : 
     798          12 :             if (mpParentFrame)
     799             :             {
     800          12 :                 const SwFrmFmt &rFrmFmt = mpParentFrame->GetFrmFmt();
     801             : 
     802          12 :                 SfxItemSet aSet(pDoc->GetAttrPool(), RES_FRMATR_BEGIN,
     803          12 :                     RES_FRMATR_END-1);
     804          12 :                 aSet.Set(rFrmFmt.GetAttrSet());
     805             : 
     806             :                 // Fly als Zeichen werden bei uns zu Absatz-gebundenen
     807             :                 // jetzt den Abstand vom Absatz-Rand setzen
     808          12 :                 if (pFlyOffset)
     809             :                 {
     810           0 :                     aSet.Put(SwFmtHoriOrient(pFlyOffset->X()));
     811           0 :                     aSet.Put(SwFmtVertOrient(pFlyOffset->Y()));
     812           0 :                     SwFmtAnchor aAnchor(rFrmFmt.GetAnchor());
     813           0 :                     aAnchor.SetType(eNewAnchorType);
     814           0 :                     aSet.Put(aAnchor);
     815             :                 }
     816             : 
     817          12 :                 if (SFX_ITEM_SET != aSet.GetItemState(RES_SURROUND))
     818           0 :                     aSet.Put(SwFmtSurround(SURROUND_NONE));
     819             : 
     820          12 :                 bOutFlyFrmAttrs = true;
     821             :                 //script doesn't matter if not exporting chp
     822             :                 OutputItemSet(aSet, true, false,
     823          12 :                     i18n::ScriptType::LATIN, mbExportModeRTF);
     824          12 :                 bOutFlyFrmAttrs = false;
     825             : 
     826          12 :                 bCallOutSet = false;
     827             :             }
     828             :         }
     829          12 :         break;
     830             :     case RES_FRMFMT:
     831         122 :         break;
     832             :     default:
     833             :         OSL_ENSURE( !this, "Which format is exported here?" );
     834           0 :         break;
     835             :     }
     836             : 
     837        1718 :     if( bCallOutSet )
     838        1706 :         OutputItemSet( rFmt.GetAttrSet(), bPapFmt, bChpFmt,
     839        3412 :             i18n::ScriptType::LATIN, mbExportModeRTF);
     840        1718 :     pOutFmtNode = pOldMod;
     841        1718 : }
     842             : 
     843           4 : bool MSWordExportBase::HasRefToObject( sal_uInt16 nTyp, const rtl::OUString* pName, sal_uInt16 nSeqNo )
     844             : {
     845             :     const SwTxtNode* pNd;
     846             : 
     847           4 :     SwFieldType* pType = pDoc->GetSysFldType( RES_GETREFFLD );
     848           4 :     SwIterator<SwFmtFld, SwFieldType> aFmtFlds( *pType );
     849           4 :     for ( SwFmtFld* pFld = aFmtFlds.First(); pFld; pFld = aFmtFlds.Next() )
     850             :     {
     851           0 :         if ( pFld->GetTxtFld() && nTyp == pFld->GetFld()->GetSubType() &&
     852           0 :              0 != ( pNd = pFld->GetTxtFld()->GetpTxtNode() ) &&
     853           0 :              pNd->GetNodes().IsDocNodes() )
     854             :         {
     855           0 :             const SwGetRefField& rRFld = *static_cast< SwGetRefField* >( pFld->GetFld() );
     856           0 :             switch ( nTyp )
     857             :             {
     858             :                 case REF_BOOKMARK:
     859             :                 case REF_SETREFATTR:
     860           0 :                     if ( pName && *pName == rRFld.GetSetRefName() )
     861           0 :                         return true;
     862           0 :                     break;
     863             :                 case REF_FOOTNOTE:
     864             :                 case REF_ENDNOTE:
     865           0 :                     if ( nSeqNo == rRFld.GetSeqNo() )
     866           0 :                         return true;
     867           0 :                     break;
     868             :                 case REF_SEQUENCEFLD:
     869           0 :                     break;      // ???
     870             :                 case REF_OUTLINE:
     871           0 :                     break;      // ???
     872             :             }
     873             :         }
     874             :     }
     875             : 
     876           4 :     return false;
     877             : }
     878             : 
     879           0 : String MSWordExportBase::GetBookmarkName( sal_uInt16 nTyp, const rtl::OUString* pName, sal_uInt16 nSeqNo )
     880             : {
     881           0 :     String sRet;
     882           0 :     switch ( nTyp )
     883             :     {
     884             :         case REF_SETREFATTR:
     885           0 :             if ( pName )
     886             :             {
     887           0 :                 sRet.AppendAscii( "Ref_" );
     888           0 :                 sRet += *pName;
     889             :             }
     890           0 :             break;
     891             :         case REF_SEQUENCEFLD:
     892           0 :             break;      // ???
     893             :         case REF_BOOKMARK:
     894           0 :             if ( pName )
     895           0 :                 sRet = *pName;
     896           0 :             break;
     897             :         case REF_OUTLINE:
     898           0 :             break;      // ???
     899             :         case REF_FOOTNOTE:
     900           0 :             sRet.AppendAscii( "_RefF" );
     901           0 :             sRet += String::CreateFromInt32( nSeqNo );
     902           0 :             break;
     903             :         case REF_ENDNOTE:
     904           0 :             sRet.AppendAscii( "_RefE" );
     905           0 :             sRet += String::CreateFromInt32( nSeqNo );
     906           0 :             break;
     907             :     }
     908           0 :     return BookmarkToWord( sRet ); // #i43956# - encode bookmark accordingly
     909             : }
     910             : 
     911             : //-----------------------------------------------------------------------
     912             : /* File CHRATR.HXX: */
     913          94 : void WW8AttributeOutput::RTLAndCJKState( bool bIsRTL, sal_uInt16 nScript )
     914             : {
     915          94 :     if ( m_rWW8Export.bWrtWW8 && bIsRTL )
     916             :     {
     917           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CFBiDi );
     918           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)1 );
     919             :     }
     920             : 
     921             :     // #i46087# patch from james_clark; complex texts needs the undocumented SPRM CComplexScript with param 0x81.
     922          94 :     if ( m_rWW8Export.bWrtWW8 && nScript == i18n::ScriptType::COMPLEX && !bIsRTL )
     923             :     {
     924           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CComplexScript );
     925           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x81 );
     926           0 :         m_rWW8Export.pDop->bUseThaiLineBreakingRules = true;
     927             :     }
     928          94 : }
     929             : 
     930          88 : void WW8AttributeOutput::EndParagraph( ww8::WW8TableNodeInfoInner::Pointer_t pTextNodeInfoInner )
     931             : {
     932          88 :     m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
     933          88 :     m_rWW8Export.pO->clear();
     934             : 
     935          88 :     if ( pTextNodeInfoInner.get() != NULL )
     936             :     {
     937           0 :         if ( pTextNodeInfoInner->isEndOfLine() )
     938             :         {
     939           0 :             TableRowEnd( pTextNodeInfoInner->getDepth() );
     940             : 
     941             :             SVBT16 nSty;
     942           0 :             ShortToSVBT16( 0, nSty );
     943           0 :             m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nSty, (sal_uInt8*)&nSty+2 );     // Style #
     944           0 :             TableInfoRow( pTextNodeInfoInner );
     945           0 :             m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data());
     946           0 :             m_rWW8Export.pO->clear();
     947             :         }
     948             :     }
     949          88 : }
     950             : 
     951          94 : void WW8AttributeOutput::StartRunProperties()
     952             : {
     953          94 :     WW8_WrPlcFld* pCurrentFields = m_rWW8Export.CurrentFieldPlc();
     954          94 :     m_nFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0;
     955          94 : }
     956             : 
     957             : 
     958          94 : void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
     959             : {
     960          94 :     if (pRedlineData)
     961             :     {
     962           0 :         const String &rComment = pRedlineData->GetComment();
     963             :         //Only possible to export to main text
     964           0 :         if (rComment.Len() && (m_rWW8Export.nTxtTyp == TXT_MAINTEXT))
     965             :         {
     966           0 :             if (m_rWW8Export.pAtn->IsNewRedlineComment(pRedlineData))
     967             :             {
     968           0 :                 m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pRedlineData );
     969           0 :                 m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
     970             :             }
     971             :         }
     972             :     }
     973          94 : }
     974             : 
     975          94 : void WW8AttributeOutput::EndRunProperties( const SwRedlineData* pRedlineData )
     976             : {
     977          94 :     Redline( pRedlineData );
     978             : 
     979          94 :     WW8_WrPlcFld* pCurrentFields = m_rWW8Export.CurrentFieldPlc();
     980          94 :     sal_uInt16 nNewFieldResults = pCurrentFields ? pCurrentFields->ResultCount() : 0;
     981             : 
     982          94 :     bool bExportedFieldResult = ( m_nFieldResults != nNewFieldResults );
     983             : 
     984             :     // If we have exported a field result, then we will have been forced to
     985             :     // split up the text into a 0x13, 0x14, <result> 0x15 sequence with the
     986             :     // properties forced out at the end of the result, so the 0x15 itself
     987             :     // should remain clean of all other attributes to avoid #iXXXXX#
     988          94 :     if ( !bExportedFieldResult )
     989             :     {
     990          94 :         m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
     991         188 :                 m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
     992             :     }
     993          94 :     m_rWW8Export.pO->clear();
     994          94 : }
     995             : 
     996          76 : void WW8AttributeOutput::RunText( const String& rText, rtl_TextEncoding eCharSet )
     997             : {
     998          76 :     RawText( rText, m_rWW8Export.bWrtWW8, eCharSet );
     999          76 : }
    1000             : 
    1001          76 : void WW8AttributeOutput::RawText( const String& rText, bool bForceUnicode, rtl_TextEncoding eCharSet )
    1002             : {
    1003          76 :     m_rWW8Export.OutSwString( rText, 0, rText.Len(), bForceUnicode, eCharSet );
    1004          76 : }
    1005             : 
    1006          88 : void WW8AttributeOutput::OutputFKP()
    1007             : {
    1008          88 :     if ( !m_rWW8Export.pO->empty() )
    1009             :     {
    1010           0 :         m_rWW8Export.pChpPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(),
    1011           0 :                 m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
    1012           0 :         m_rWW8Export.pO->clear();
    1013             :     }
    1014          88 : }
    1015             : 
    1016          88 : void WW8AttributeOutput::ParagraphStyle( sal_uInt16 nStyle )
    1017             : {
    1018             :     OSL_ENSURE( m_rWW8Export.pO->empty(), " pO ist am ZeilenEnde nicht leer" );
    1019             : 
    1020             :     SVBT16 nSty;
    1021          88 :     ShortToSVBT16( nStyle, nSty );
    1022          88 :     m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nSty, (sal_uInt8*)&nSty+2 );     // Style #
    1023          88 : }
    1024             : 
    1025          26 : void WW8AttributeOutput::OutputWW8Attribute( sal_uInt8 nId, bool bVal )
    1026             : {
    1027          26 :     if ( m_rWW8Export.bWrtWW8 )
    1028          26 :         m_rWW8Export.InsUInt16( 8 == nId ? NS_sprm::LN_CFDStrike : NS_sprm::LN_CFBold + nId );
    1029           0 :     else if (8 == nId )
    1030          26 :         return; // no such attribute in WW6
    1031             :     else
    1032           0 :         m_rWW8Export.pO->push_back( 85 + nId );
    1033             : 
    1034          26 :     m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
    1035             : }
    1036             : 
    1037          26 : void WW8AttributeOutput::OutputWW8AttributeCTL( sal_uInt8 nId, bool bVal )
    1038             : {
    1039             :     OSL_ENSURE( nId <= 1, "out of range" );
    1040          26 :     if ( !m_rWW8Export.bWrtWW8 || nId > 1 )
    1041          26 :         return;
    1042             : 
    1043          26 :     m_rWW8Export.InsUInt16( NS_sprm::LN_CFBoldBi + nId );
    1044          26 :     m_rWW8Export.pO->push_back( bVal ? 1 : 0 );
    1045             : }
    1046             : 
    1047          40 : void WW8AttributeOutput::CharFont( const SvxFontItem& rFont )
    1048             : {
    1049          40 :     sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
    1050             : 
    1051          40 :     if ( m_rWW8Export.bWrtWW8 )
    1052             :     {
    1053          40 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc0 );
    1054          40 :         m_rWW8Export.InsUInt16( nFontID );
    1055          40 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc2 );
    1056             :     }
    1057             :     else
    1058           0 :         m_rWW8Export.pO->push_back( 93 );
    1059             : 
    1060          40 :     m_rWW8Export.InsUInt16( nFontID );
    1061          40 : }
    1062             : 
    1063          44 : void WW8AttributeOutput::CharFontCTL( const SvxFontItem& rFont )
    1064             : {
    1065             :     //Can only export in 8+, in 7- export as normal varient and expect that
    1066             :     //upperlevel code has blocked exporting clobbering attributes
    1067          44 :     sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
    1068          44 :     if ( m_rWW8Export.bWrtWW8 )
    1069          44 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CFtcBi );
    1070             :     else
    1071           0 :         m_rWW8Export.pO->push_back( 93 );
    1072          44 :     m_rWW8Export.InsUInt16( nFontID );
    1073          44 : }
    1074             : 
    1075          36 : void WW8AttributeOutput::CharFontCJK( const SvxFontItem& rFont )
    1076             : {
    1077             :     //Can only export in 8+, in 7- export as normal varient and expect that
    1078             :     //upperlevel code has blocked exporting clobbering attributes
    1079          36 :     sal_uInt16 nFontID = m_rWW8Export.GetId( rFont );
    1080          36 :     if ( m_rWW8Export.bWrtWW8 )
    1081          36 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CRgFtc1 );
    1082             :     else
    1083           0 :         m_rWW8Export.pO->push_back( 93 );
    1084          36 :     m_rWW8Export.InsUInt16( nFontID );
    1085          36 : }
    1086             : 
    1087          12 : void WW8AttributeOutput::CharWeightCTL( const SvxWeightItem& rWeight )
    1088             : {
    1089             :     //Can only export in 8+, in 7- export as normal varient and expect that
    1090             :     //upperlevel code has blocked exporting clobbering attributes
    1091          12 :     if (m_rWW8Export.bWrtWW8)
    1092             :     {
    1093          12 :         OutputWW8AttributeCTL( 0, WEIGHT_BOLD == rWeight.GetWeight());
    1094             :     }
    1095             :     else
    1096             :     {
    1097           0 :         OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight());
    1098             :     }
    1099          12 : }
    1100             : 
    1101          14 : void WW8AttributeOutput::CharPostureCTL( const SvxPostureItem& rPosture )
    1102             : {
    1103             :     // Can only export in 8+, in 7- export as normal varient and expect that
    1104             :     // upperlevel code has blocked exporting clobbering attributes
    1105          14 :     if (m_rWW8Export.bWrtWW8)
    1106             :     {
    1107          14 :         OutputWW8AttributeCTL( 1, ITALIC_NONE != rPosture.GetPosture() );
    1108             :     }
    1109             :     else
    1110             :     {
    1111           0 :         OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() );
    1112             :     }
    1113          14 : }
    1114             : 
    1115          14 : void WW8AttributeOutput::CharPosture( const SvxPostureItem& rPosture )
    1116             : {
    1117          14 :     OutputWW8Attribute( 1, ITALIC_NONE != rPosture.GetPosture() );
    1118          14 : }
    1119             : 
    1120          12 : void WW8AttributeOutput::CharWeight( const SvxWeightItem& rWeight )
    1121             : {
    1122          12 :     OutputWW8Attribute( 0, WEIGHT_BOLD == rWeight.GetWeight() );
    1123          12 : }
    1124             : 
    1125             : // Shadowed und Contour are not in WW-UI. JP: ??
    1126           0 : void WW8AttributeOutput::CharContour( const SvxContourItem& rContour )
    1127             : {
    1128           0 :     OutputWW8Attribute( 3, rContour.GetValue() ? true : false);
    1129           0 : }
    1130             : 
    1131           0 : void WW8AttributeOutput::CharShadow( const SvxShadowedItem& rShadow )
    1132             : {
    1133           0 :     OutputWW8Attribute( 4, rShadow.GetValue() ? true : false);
    1134           0 : }
    1135             : 
    1136           0 : void WW8AttributeOutput::CharKerning( const SvxKerningItem& rKerning )
    1137             : {
    1138           0 :     if ( m_rWW8Export.bWrtWW8 )
    1139           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CDxaSpace );
    1140             :     else
    1141           0 :         m_rWW8Export.pO->push_back( 96 );
    1142             : 
    1143           0 :     m_rWW8Export.InsUInt16( rKerning.GetValue() );
    1144           0 : }
    1145             : 
    1146           4 : void WW8AttributeOutput::CharAutoKern( const SvxAutoKernItem& rAutoKern )
    1147             : {
    1148           4 :     if ( m_rWW8Export.bWrtWW8 )
    1149           4 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsKern );
    1150             :     else
    1151           0 :         m_rWW8Export.pO->push_back( 107 );
    1152             : 
    1153           4 :     m_rWW8Export.InsUInt16( rAutoKern.GetValue() ? 1 : 0 );
    1154           4 : }
    1155             : 
    1156           0 : void WW8AttributeOutput::CharAnimatedText( const SvxBlinkItem& rBlink )
    1157             : {
    1158           0 :     if ( m_rWW8Export.bWrtWW8 )
    1159             :     {
    1160           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CSfxText );
    1161             :         // At the moment the only animated text effect we support is blinking
    1162           0 :         m_rWW8Export.InsUInt16( rBlink.GetValue() ? 2 : 0 );
    1163             :     }
    1164           0 : }
    1165             : 
    1166           0 : void WW8AttributeOutput::CharCrossedOut( const SvxCrossedOutItem& rCrossed )
    1167             : {
    1168           0 :     FontStrikeout eSt = rCrossed.GetStrikeout();
    1169           0 :     if ( STRIKEOUT_DOUBLE == eSt )
    1170             :     {
    1171           0 :         OutputWW8Attribute( 8, true );
    1172           0 :         return;
    1173             :     }
    1174           0 :     if ( STRIKEOUT_NONE != eSt )
    1175             :     {
    1176           0 :         OutputWW8Attribute( 2, true );
    1177           0 :         return;
    1178             :     }
    1179             : 
    1180             :     // otherwise both off
    1181           0 :     OutputWW8Attribute( 8, false );
    1182           0 :     OutputWW8Attribute( 2, false );
    1183             : }
    1184             : 
    1185           0 : void WW8AttributeOutput::CharCaseMap( const SvxCaseMapItem& rCaseMap )
    1186             : {
    1187           0 :     sal_uInt16 eSt = rCaseMap.GetValue();
    1188           0 :     switch ( eSt )
    1189             :     {
    1190             :         case SVX_CASEMAP_KAPITAELCHEN:
    1191           0 :             OutputWW8Attribute( 5, true );
    1192           0 :             return;
    1193             :         case SVX_CASEMAP_VERSALIEN:
    1194           0 :             OutputWW8Attribute( 6, true );
    1195           0 :             return;
    1196             :         case SVX_CASEMAP_TITEL:
    1197             :             // no such feature in word
    1198           0 :             break;
    1199             :         default:
    1200             :             // otherwise both off
    1201           0 :             OutputWW8Attribute( 5, false );
    1202           0 :             OutputWW8Attribute( 6, false );
    1203           0 :             return;
    1204             :     }
    1205             : }
    1206             : 
    1207           0 : void WW8AttributeOutput::CharHidden( const SvxCharHiddenItem& rHidden )
    1208             : {
    1209           0 :     OutputWW8Attribute( 7, rHidden.GetValue() );
    1210           0 : }
    1211             : 
    1212           2 : void WW8AttributeOutput::CharUnderline( const SvxUnderlineItem& rUnderline )
    1213             : {
    1214           2 :     if ( m_rWW8Export.bWrtWW8 )
    1215           2 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CKul );
    1216             :     else
    1217           0 :         m_rWW8Export.pO->push_back( 94 );
    1218             : 
    1219           2 :     const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_CHRATR_WORDLINEMODE );
    1220           2 :     bool bWord = false;
    1221           2 :     if (pItem)
    1222           0 :         bWord = ((const SvxWordLineModeItem*)pItem)->GetValue() ? true : false;
    1223             : 
    1224             :     // WW95 - parameters:   0 = none,   1 = single, 2 = by Word,
    1225             :     //                      3 = double, 4 = dotted, 5 = hidden
    1226             :     // WW97 - additional parameters:
    1227             :     //                      6 = thick,   7 = dash,       8 = dot(not used)
    1228             :     //                      9 = dotdash 10 = dotdotdash, 11 = wave
    1229           2 :     sal_uInt8 b = 0;
    1230           2 :     switch ( rUnderline.GetLineStyle() )
    1231             :     {
    1232             :         case UNDERLINE_SINGLE:
    1233           2 :             b = ( bWord ) ? 2 : 1;
    1234           2 :             break;
    1235             :         case UNDERLINE_BOLD:
    1236           0 :             b = m_rWW8Export.bWrtWW8 ?  6 : 1;
    1237           0 :             break;
    1238             :         case UNDERLINE_DOUBLE:
    1239           0 :             b = 3;
    1240           0 :             break;
    1241             :         case UNDERLINE_DOTTED:
    1242           0 :             b = 4;
    1243           0 :             break;
    1244             :         case UNDERLINE_DASH:
    1245           0 :             b = m_rWW8Export.bWrtWW8 ?  7 : 4;
    1246           0 :             break;
    1247             :         case UNDERLINE_DASHDOT:
    1248           0 :             b = m_rWW8Export.bWrtWW8 ?  9 : 4;
    1249           0 :             break;
    1250             :         case UNDERLINE_DASHDOTDOT:
    1251           0 :             b = m_rWW8Export.bWrtWW8 ? 10 : 4;
    1252           0 :             break;
    1253             :         case UNDERLINE_WAVE:
    1254           0 :             b = m_rWW8Export.bWrtWW8 ? 11 : 3;
    1255           0 :             break;
    1256             :         // ------------  new in WW2000  -------------------------------------
    1257             :         case UNDERLINE_BOLDDOTTED:
    1258           0 :             b = m_rWW8Export.bWrtWW8 ? 20 : 4;
    1259           0 :             break;
    1260             :         case UNDERLINE_BOLDDASH:
    1261           0 :             b = m_rWW8Export.bWrtWW8 ? 23 : 4;
    1262           0 :             break;
    1263             :         case UNDERLINE_LONGDASH:
    1264           0 :             b = m_rWW8Export.bWrtWW8 ? 39 : 4;
    1265           0 :             break;
    1266             :         case UNDERLINE_BOLDLONGDASH:
    1267           0 :             b = m_rWW8Export.bWrtWW8 ? 55 : 4;
    1268           0 :             break;
    1269             :         case UNDERLINE_BOLDDASHDOT:
    1270           0 :             b = m_rWW8Export.bWrtWW8 ? 25 : 4;
    1271           0 :             break;
    1272             :         case UNDERLINE_BOLDDASHDOTDOT:
    1273           0 :             b = m_rWW8Export.bWrtWW8 ? 26 : 4;
    1274           0 :             break;
    1275             :         case UNDERLINE_BOLDWAVE:
    1276           0 :             b = m_rWW8Export.bWrtWW8 ? 27 : 3;
    1277           0 :             break;
    1278             :         case UNDERLINE_DOUBLEWAVE:
    1279           0 :             b = m_rWW8Export.bWrtWW8 ? 43 : 3;
    1280           0 :             break;
    1281             :         case UNDERLINE_NONE:
    1282           0 :             b = 0;
    1283           0 :             break;
    1284             :         default:
    1285             :             OSL_ENSURE( rUnderline.GetLineStyle() == UNDERLINE_NONE, "Unhandled underline type" );
    1286           0 :             break;
    1287             :     }
    1288             : 
    1289           2 :     m_rWW8Export.pO->push_back( b );
    1290           2 : }
    1291             : 
    1292          80 : void WW8AttributeOutput::CharLanguage( const SvxLanguageItem& rLanguage )
    1293             : {
    1294          80 :     sal_uInt16 nId = 0;
    1295          80 :     if ( m_rWW8Export.bWrtWW8 )
    1296             :     {
    1297          80 :         switch ( rLanguage.Which() )
    1298             :         {
    1299             :             case RES_CHRATR_LANGUAGE:
    1300          56 :                 nId = NS_sprm::LN_CRgLid0_80;
    1301          56 :                 break;
    1302             :             case RES_CHRATR_CJK_LANGUAGE:
    1303          14 :                 nId = NS_sprm::LN_CRgLid1_80;
    1304          14 :                 break;
    1305             :             case RES_CHRATR_CTL_LANGUAGE:
    1306          10 :                 nId = NS_sprm::LN_CLidBi;
    1307          10 :                 break;
    1308             :         }
    1309             :     }
    1310             :     else
    1311           0 :         nId = 97;
    1312             : 
    1313          80 :     if ( nId )
    1314             :     {
    1315          80 :         if ( m_rWW8Export.bWrtWW8 ) // use sprmCRgLid0_80 rather than sprmCLid
    1316          80 :             m_rWW8Export.InsUInt16( nId );
    1317             :         else
    1318           0 :             m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nId) );
    1319          80 :         m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
    1320             : 
    1321             :         // Word 2000 and above apparently require both old and new versions of
    1322             :         // these sprms to be set, without it spellchecking doesn't work
    1323          80 :         if ( nId == NS_sprm::LN_CRgLid0_80 )
    1324             :         {
    1325          56 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CRgLid0 );
    1326          56 :             m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
    1327             :         }
    1328          24 :         else if ( nId == NS_sprm::LN_CRgLid1_80 )
    1329             :         {
    1330          14 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CRgLid1 );
    1331          14 :             m_rWW8Export.InsUInt16( rLanguage.GetLanguage() );
    1332             :         }
    1333             :     }
    1334          80 : }
    1335             : 
    1336           8 : void WW8AttributeOutput::CharEscapement( const SvxEscapementItem& rEscapement )
    1337             : {
    1338           8 :     sal_uInt8 b = 0xFF;
    1339           8 :     short nEsc = rEscapement.GetEsc(), nProp = rEscapement.GetProp();
    1340           8 :     if ( !nEsc )
    1341             :     {
    1342           0 :         b = 0;
    1343           0 :         nEsc = 0;
    1344           0 :         nProp = 100;
    1345             :     }
    1346           8 :     else if ( DFLT_ESC_PROP == nProp )
    1347             :     {
    1348           8 :         if ( DFLT_ESC_SUB == nEsc || DFLT_ESC_AUTO_SUB == nEsc )
    1349           0 :             b = 2;
    1350           8 :         else if ( DFLT_ESC_SUPER == nEsc || DFLT_ESC_AUTO_SUPER == nEsc )
    1351           8 :             b = 1;
    1352             :     }
    1353             : 
    1354           8 :     if ( 0xFF != b )
    1355             :     {
    1356           8 :         if ( m_rWW8Export.bWrtWW8 )
    1357           8 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CIss );
    1358             :         else
    1359           0 :             m_rWW8Export.pO->push_back( 104 );
    1360             : 
    1361           8 :         m_rWW8Export.pO->push_back( b );
    1362             :     }
    1363             : 
    1364           8 :     if ( 0 == b || 0xFF == b )
    1365             :     {
    1366             :         long nHeight = ((SvxFontHeightItem&)m_rWW8Export.GetItem(
    1367           0 :                                     RES_CHRATR_FONTSIZE )).GetHeight();
    1368           0 :         if( m_rWW8Export.bWrtWW8 )
    1369           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsPos );
    1370             :         else
    1371           0 :             m_rWW8Export.pO->push_back( 101 );
    1372             : 
    1373           0 :         m_rWW8Export.InsUInt16( (short)(( nHeight * nEsc + 500 ) / 1000 ));
    1374             : 
    1375           0 :         if( 100 != nProp || !b )
    1376             :         {
    1377           0 :             if( m_rWW8Export.bWrtWW8 )
    1378           0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_CHps );
    1379             :             else
    1380           0 :                 m_rWW8Export.pO->push_back( 99 );
    1381             : 
    1382             :             m_rWW8Export.InsUInt16(
    1383           0 :                 msword_cast<sal_uInt16>((nHeight * nProp + 500 ) / 1000));
    1384             :         }
    1385             :     }
    1386           8 : }
    1387             : 
    1388         158 : void WW8AttributeOutput::CharFontSize( const SvxFontHeightItem& rHeight )
    1389             : {
    1390         158 :     sal_uInt16 nId = 0;
    1391         158 :     if ( m_rWW8Export.bWrtWW8 )
    1392             :     {
    1393         158 :         switch ( rHeight.Which() )
    1394             :         {
    1395             :             case RES_CHRATR_FONTSIZE:
    1396             :             case RES_CHRATR_CJK_FONTSIZE:
    1397          82 :                 nId = NS_sprm::LN_CHps;
    1398          82 :                 break;
    1399             :             case RES_CHRATR_CTL_FONTSIZE:
    1400          76 :                 nId = NS_sprm::LN_CHpsBi;
    1401          76 :                 break;
    1402             :         }
    1403             :     }
    1404             :     else
    1405           0 :         nId = 99;
    1406             : 
    1407         158 :     if ( nId )
    1408             :     {
    1409         158 :         if ( m_rWW8Export.bWrtWW8 )
    1410         158 :             m_rWW8Export.InsUInt16( nId );
    1411             :         else
    1412           0 :             m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nId) );
    1413             : 
    1414         158 :         m_rWW8Export.InsUInt16( (sal_uInt16)(( rHeight.GetHeight() + 5 ) / 10 ) );
    1415             :     }
    1416         158 : }
    1417             : 
    1418           0 : void WW8AttributeOutput::CharScaleWidth( const SvxCharScaleWidthItem& rScaleWidth )
    1419             : {
    1420           0 :     if ( m_rWW8Export.bWrtWW8 )
    1421             :     {
    1422           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CCharScale );
    1423           0 :         m_rWW8Export.InsUInt16( rScaleWidth.GetValue() );
    1424             :     }
    1425           0 : }
    1426             : 
    1427           0 : void WW8AttributeOutput::CharRelief( const SvxCharReliefItem& rRelief )
    1428             : {
    1429           0 :     if ( m_rWW8Export.bWrtWW8 )
    1430             :     {
    1431             :         sal_uInt16 nId;
    1432           0 :         switch ( rRelief.GetValue() )
    1433             :         {
    1434           0 :             case RELIEF_EMBOSSED:   nId = NS_sprm::LN_CFEmboss;     break;
    1435           0 :             case RELIEF_ENGRAVED:   nId = NS_sprm::LN_CFImprint;    break;
    1436           0 :             default:                nId = 0;                        break;
    1437             :         }
    1438             : 
    1439           0 :         if( nId )
    1440             :         {
    1441           0 :             m_rWW8Export.InsUInt16( nId );
    1442           0 :             m_rWW8Export.pO->push_back( (sal_uInt8)0x81 );
    1443             :         }
    1444             :         else
    1445             :         {
    1446             :             // switch both flags off
    1447           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CFEmboss );
    1448           0 :             m_rWW8Export.pO->push_back( (sal_uInt8)0x0 );
    1449           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CFImprint );
    1450           0 :             m_rWW8Export.pO->push_back( (sal_uInt8)0x0 );
    1451             :         }
    1452             :     }
    1453           0 : }
    1454             : 
    1455           0 : void WW8AttributeOutput::CharRotate( const SvxCharRotateItem& rRotate )
    1456             : {
    1457             :     // #i28331# - check that a Value is set
    1458           0 :     if ( !rRotate.GetValue() )
    1459           0 :         return;
    1460             : 
    1461           0 :     if ( m_rWW8Export.bWrtWW8 && !m_rWW8Export.IsInTable() )
    1462             :     {
    1463             :         // #i36867 In word the text in a table is rotated via the TC or NS_sprm::LN_TTextFlow
    1464             :         // This means you can only rotate all or none of the text adding NS_sprm::LN_CEastAsianLayout
    1465             :         // here corrupts the table, hence !m_rWW8Export.bIsInTable
    1466             : 
    1467           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CEastAsianLayout );
    1468           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x06 ); //len 6
    1469           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x01 );
    1470             : 
    1471           0 :         m_rWW8Export.InsUInt16( rRotate.IsFitToLine() ? 1 : 0 );
    1472             :         static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
    1473           0 :         m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
    1474             :     }
    1475             : }
    1476             : 
    1477           0 : void WW8AttributeOutput::CharEmphasisMark( const SvxEmphasisMarkItem& rEmphasisMark )
    1478             : {
    1479           0 :     if ( m_rWW8Export.bWrtWW8 )
    1480             :     {
    1481             :         sal_uInt8 nVal;
    1482           0 :         switch ( rEmphasisMark.GetValue() )
    1483             :         {
    1484           0 :             case EMPHASISMARK_NONE:             nVal = 0;   break;
    1485           0 :             case EMPHASISMARK_SIDE_DOTS:        nVal = 2;   break;
    1486           0 :             case EMPHASISMARK_CIRCLE_ABOVE:     nVal = 3;   break;
    1487           0 :             case EMPHASISMARK_DOTS_BELOW:       nVal = 4;   break;
    1488             :             // case 1:
    1489           0 :             default:                            nVal = 1;   break;
    1490             :         }
    1491             : 
    1492           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CKcd );
    1493           0 :         m_rWW8Export.pO->push_back( nVal );
    1494             :     }
    1495           0 : }
    1496             : 
    1497             : // TransCol uebersetzt SW-Farben in WW. Heraus kommt die bei WW fuer
    1498             : // Text- und Hintergrundfarbe benutzte Codierung.
    1499             : // Gibt es keine direkte Entsprechung, dann wird versucht, eine moeglichst
    1500             : // aehnliche WW-Farbe zu finden.
    1501             : // return: 5-Bit-Wert ( 0..16 )
    1502          18 : sal_uInt8 WW8Export::TransCol( const Color& rCol )
    1503             : {
    1504          18 :     sal_uInt8 nCol = 0;      // ->Auto
    1505          18 :     switch( rCol.GetColor() )
    1506             :     {
    1507           4 :     case COL_BLACK:         nCol = 1;   break;
    1508           2 :     case COL_BLUE:          nCol = 9;   break;
    1509           0 :     case COL_GREEN:         nCol = 11;  break;
    1510           0 :     case COL_CYAN:          nCol = 10;  break;
    1511           0 :     case COL_RED:           nCol = 13;  break;
    1512           0 :     case COL_MAGENTA:       nCol = 12;  break;
    1513           0 :     case COL_BROWN:         nCol = 14;  break;
    1514           0 :     case COL_GRAY:          nCol = 15;  break;
    1515           0 :     case COL_LIGHTGRAY:     nCol = 16;  break;
    1516           0 :     case COL_LIGHTBLUE:     nCol = 2;   break;
    1517           0 :     case COL_LIGHTGREEN:    nCol = 4;   break;
    1518           0 :     case COL_LIGHTCYAN:     nCol = 3;   break;
    1519           0 :     case COL_LIGHTRED:      nCol = 6;   break;
    1520           0 :     case COL_LIGHTMAGENTA:  nCol = 5;   break;
    1521           0 :     case COL_YELLOW:        nCol = 7;   break;
    1522           0 :     case COL_WHITE:         nCol = 8;   break;
    1523           8 :     case COL_AUTO:          nCol = 0;   break;
    1524             : 
    1525             :     default:
    1526           4 :         if( !pBmpPal )
    1527             :         {
    1528           2 :             pBmpPal = new BitmapPalette( 16 );
    1529             :             static const ColorData aColArr[ 16 ] = {
    1530             :                 COL_BLACK,      COL_LIGHTBLUE,  COL_LIGHTCYAN,  COL_LIGHTGREEN,
    1531             :                 COL_LIGHTMAGENTA,COL_LIGHTRED,  COL_YELLOW,     COL_WHITE,
    1532             :                 COL_BLUE,       COL_CYAN,       COL_GREEN,      COL_MAGENTA,
    1533             :                 COL_RED,        COL_BROWN,      COL_GRAY,       COL_LIGHTGRAY
    1534             :             };
    1535             : 
    1536          34 :             for( sal_uInt16 i = 0; i < 16; ++i )
    1537          32 :                 pBmpPal->operator[]( i ) = Color( aColArr[ i ] );
    1538             :         }
    1539           4 :         nCol = static_cast< sal_uInt8 >(pBmpPal->GetBestIndex( rCol ) + 1);
    1540           4 :         break;
    1541             :     }
    1542          18 :     return nCol;
    1543             : }
    1544             : 
    1545             : // TransBrush uebersetzt SW-Brushes in WW. Heraus kommt WW8_SHD.
    1546             : // Nicht-Standardfarben des SW werden noch nicht in die
    1547             : // Misch-Werte ( 0 .. 95% ) vom WW uebersetzt.
    1548             : // Return: Echte Brush ( nicht transparent )
    1549             : // auch bei Transparent wird z.B. fuer Tabellen eine transparente Brush
    1550             : // geliefert
    1551           6 : bool WW8Export::TransBrush(const Color& rCol, WW8_SHD& rShd)
    1552             : {
    1553           6 :     if( rCol.GetTransparency() )
    1554           2 :         rShd = WW8_SHD();               // alles Nullen : transparent
    1555             :     else
    1556             :     {
    1557           4 :         rShd.SetFore( 0);
    1558           4 :         rShd.SetBack( TransCol( rCol ) );
    1559           4 :         rShd.SetStyle( bWrtWW8, 0 );
    1560             :     }
    1561           6 :     return !rCol.GetTransparency();
    1562             : }
    1563             : 
    1564           6 : sal_uInt32 SuitableBGColor(sal_uInt32 nIn)
    1565             : {
    1566           6 :     if (nIn == COL_AUTO)
    1567           2 :         return 0xFF000000;
    1568           4 :     return wwUtility::RGBToBGR(nIn);
    1569             : }
    1570             : 
    1571          10 : void WW8AttributeOutput::CharColor( const SvxColorItem& rColor )
    1572             : {
    1573          10 :     if ( m_rWW8Export.bWrtWW8 )
    1574          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CIco );
    1575             :     else
    1576           0 :         m_rWW8Export.pO->push_back( 98 );
    1577             : 
    1578          10 :     sal_uInt8 nColor = m_rWW8Export.TransCol( rColor.GetValue() );
    1579          10 :     m_rWW8Export.pO->push_back( nColor );
    1580             : 
    1581          10 :     if ( m_rWW8Export.bWrtWW8 && nColor )
    1582             :     {
    1583           2 :         m_rWW8Export.InsUInt16( 0x6870 );
    1584           2 :         m_rWW8Export.InsUInt32( wwUtility::RGBToBGR( rColor.GetValue().GetColor() ) );
    1585             :     }
    1586          10 : }
    1587             : 
    1588           0 : void WW8AttributeOutput::CharBackground( const SvxBrushItem& rBrush )
    1589             : {
    1590           0 :     if( m_rWW8Export.bWrtWW8 )   // nur WW8 kann ZeichenHintergrund
    1591             :     {
    1592           0 :         WW8_SHD aSHD;
    1593             : 
    1594           0 :         m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD );
    1595             :         // sprmCShd
    1596           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CShd );
    1597           0 :         m_rWW8Export.InsUInt16( aSHD.GetValue() );
    1598             : 
    1599             :         //Quite a few unknowns, some might be transparency or something
    1600             :         //of that nature...
    1601           0 :         m_rWW8Export.InsUInt16( 0xCA71 );
    1602           0 :         m_rWW8Export.pO->push_back( 10 );
    1603           0 :         m_rWW8Export.InsUInt32( 0xFF000000 );
    1604           0 :         m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) );
    1605           0 :         m_rWW8Export.InsUInt16( 0x0000);
    1606             :     }
    1607           0 : }
    1608             : 
    1609           0 : void WW8AttributeOutput::TextINetFormat( const SwFmtINetFmt& rINet )
    1610             : {
    1611           0 :     if ( rINet.GetValue().Len() )
    1612             :     {
    1613             :         sal_uInt16 nId;
    1614           0 :         const String& rStr = rINet.GetINetFmt();
    1615           0 :         if ( rStr.Len() )
    1616           0 :             nId = rINet.GetINetFmtId();
    1617             :         else
    1618           0 :             nId = RES_POOLCHR_INET_NORMAL;
    1619             : 
    1620           0 :         const SwCharFmt* pFmt = IsPoolUserFmt( nId )
    1621           0 :                         ? m_rWW8Export.pDoc->FindCharFmtByName( rStr )
    1622           0 :                         : m_rWW8Export.pDoc->GetCharFmtFromPool( nId );
    1623             : 
    1624           0 :         if ( m_rWW8Export.bWrtWW8 )
    1625           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd );
    1626             :         else
    1627           0 :             m_rWW8Export.pO->push_back( 80 );
    1628             : 
    1629           0 :         m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pFmt ) );
    1630             :     }
    1631           0 : }
    1632             : 
    1633             : // #i43956# - add optional parameter <pLinkStr>
    1634             : // It's needed to write the hyperlink data for a certain cross-reference
    1635             : // - it contains the name of the link target, which is a bookmark.
    1636             : // add optional parameter <bIncludeEmptyPicLocation>
    1637             : // It is needed to write an empty picture location for page number field separators
    1638           6 : static void InsertSpecialChar( WW8Export& rWrt, sal_uInt8 c,
    1639             :                                String* pLinkStr = 0L,
    1640             :                                bool bIncludeEmptyPicLocation = false )
    1641             : {
    1642           6 :     ww::bytes aItems;
    1643           6 :     rWrt.GetCurrentItems(aItems);
    1644             : 
    1645           6 :     if (c == 0x13)
    1646           2 :         rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell());
    1647             :     else
    1648           4 :         rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), aItems.data());
    1649             : 
    1650           6 :     rWrt.WriteChar(c);
    1651             : 
    1652             :     // store empty sprmCPicLocation for field separator
    1653           6 :     if ( bIncludeEmptyPicLocation &&
    1654             :          ( c == 0x13 || c == 0x14 || c == 0x15 ) )
    1655             :     {
    1656           0 :         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation );
    1657           0 :         SwWW8Writer::InsUInt32( aItems, 0x00000000 );
    1658             :     }
    1659             : 
    1660             :     // #i43956# - write hyperlink data and attributes
    1661           6 :     if ( rWrt.bWrtWW8 && c == 0x01 && pLinkStr )
    1662             :     {
    1663             :         // write hyperlink data to data stream
    1664           0 :         SvStream& rStrm = *rWrt.pDataStrm;
    1665             :         // position of hyperlink data
    1666           0 :         const sal_uInt32 nLinkPosInDataStrm = rStrm.Tell();
    1667             :         // write empty header
    1668           0 :         const sal_uInt16 nEmptyHdrLen = 0x44;
    1669           0 :         sal_uInt8 aEmptyHeader[ nEmptyHdrLen ] = { 0 };
    1670           0 :         aEmptyHeader[ 4 ] = 0x44;
    1671           0 :         rStrm.Write( aEmptyHeader, nEmptyHdrLen );
    1672             :         // writer fixed header
    1673           0 :         const sal_uInt16 nFixHdrLen = 0x19;
    1674             :         sal_uInt8 aFixHeader[ nFixHdrLen ] =
    1675             :         {
    1676             :             0x08, 0xD0, 0xC9, 0xEA, 0x79, 0xF9, 0xBA, 0xCE,
    1677             :             0x11, 0x8C, 0x82, 0x00, 0xAA, 0x00, 0x4B, 0xA9,
    1678             :             0x0B, 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
    1679             :             0x00,
    1680           0 :         };
    1681           0 :         rStrm.Write( aFixHeader, nFixHdrLen );
    1682             :         // write reference string including length+1
    1683           0 :         sal_uInt32 nStrLen( pLinkStr->Len() + 1 );
    1684           0 :         SwWW8Writer::WriteLong( rStrm, nStrLen );
    1685           0 :         SwWW8Writer::WriteString16( rStrm, *(pLinkStr), false );
    1686             :         // write additional two NULL Bytes
    1687           0 :         SwWW8Writer::WriteLong( rStrm, 0 );
    1688             :         // write length of hyperlink data
    1689           0 :         const sal_uInt32 nCurrPos = rStrm.Tell();
    1690           0 :         rStrm.Seek( nLinkPosInDataStrm );
    1691             :         SVBT32 nLen;
    1692           0 :         UInt32ToSVBT32( nCurrPos - nLinkPosInDataStrm, nLen );
    1693           0 :         rStrm.Write( nLen, 4 );
    1694           0 :         rStrm.Seek( nCurrPos );
    1695             : 
    1696             :         // write attributes of hyperlink character 0x01
    1697           0 :         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFFldVanish );
    1698           0 :         aItems.push_back( (sal_uInt8)0x81 );
    1699           0 :         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CPicLocation );
    1700           0 :         SwWW8Writer::InsUInt32( aItems, nLinkPosInDataStrm );
    1701           0 :         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFData );
    1702           0 :         aItems.push_back( (sal_uInt8)0x01 );
    1703             :     }
    1704             : 
    1705             :     //Technically we should probably Remove all attribs
    1706             :     //here for the 0x13, 0x14, 0x15, but our import
    1707             :     //is slightly lacking
    1708             :     //aItems.Remove(0, aItems.Count());
    1709             :     // fSpec-Attribute true
    1710           6 :     if( rWrt.bWrtWW8 )
    1711             :     {
    1712           6 :         SwWW8Writer::InsUInt16( aItems, NS_sprm::LN_CFSpec );
    1713           6 :         aItems.push_back( 1 );
    1714             :     }
    1715             :     else
    1716             :     {
    1717           0 :         aItems.push_back( 117 ); //sprmCFSpec
    1718           0 :         aItems.push_back( 1 );
    1719             :     }
    1720             : 
    1721           6 :     rWrt.pChpPlc->AppendFkpEntry(rWrt.Strm().Tell(), aItems.size(), aItems.data());
    1722           6 : }
    1723             : 
    1724           0 : static String lcl_GetExpandedField(const SwField &rFld)
    1725             : {
    1726           0 :     String sRet(rFld.ExpandField(true));
    1727             : 
    1728             :     //replace LF 0x0A with VT 0x0B
    1729           0 :     sRet.SearchAndReplaceAll(0x0A, 0x0B);
    1730             : 
    1731           0 :     return sRet;
    1732             : }
    1733             : 
    1734         192 : WW8_WrPlcFld* WW8Export::CurrentFieldPlc() const
    1735             : {
    1736         192 :     WW8_WrPlcFld* pFldP = NULL;
    1737         192 :     switch (nTxtTyp)
    1738             :     {
    1739             :         case TXT_MAINTEXT:
    1740         116 :             pFldP = pFldMain;
    1741         116 :             break;
    1742             :         case TXT_HDFT:
    1743          68 :             pFldP = pFldHdFt;
    1744          68 :             break;
    1745             :         case TXT_FTN:
    1746           4 :             pFldP = pFldFtn;
    1747           4 :             break;
    1748             :         case TXT_EDN:
    1749           0 :             pFldP = pFldEdn;
    1750           0 :             break;
    1751             :         case TXT_ATN:
    1752           0 :             pFldP = pFldAtn;
    1753           0 :             break;
    1754             :         case TXT_TXTBOX:
    1755           4 :             pFldP = pFldTxtBxs;
    1756           4 :             break;
    1757             :         case TXT_HFTXTBOX:
    1758           0 :             pFldP = pFldHFTxtBxs;
    1759           0 :             break;
    1760             :         default:
    1761             :             OSL_ENSURE( !this, "was ist das fuer ein SubDoc-Type?" );
    1762             :     }
    1763         192 :     return pFldP;
    1764             : }
    1765             : 
    1766           4 : void WW8Export::OutputField( const SwField* pFld, ww::eField eFldType,
    1767             :     const String& rFldCmd, sal_uInt8 nMode )
    1768             : {
    1769           4 :     bool bUnicode = IsUnicode();
    1770           4 :     WW8_WrPlcFld* pFldP = CurrentFieldPlc();
    1771             : 
    1772           4 :     const bool bIncludeEmptyPicLocation = ( eFldType == ww::ePAGE );
    1773             : 
    1774           4 :     if (WRITEFIELD_START & nMode)
    1775             :     {
    1776           2 :         sal_uInt8 aFld13[2] = { 0x13, 0x00 };  // will change
    1777             :         //#i3958#, Needed to make this field work correctly in Word 2000
    1778           2 :         if (eFldType == ww::eSHAPE)
    1779           0 :             aFld13[0] |= 0x80;
    1780           2 :         aFld13[1] = static_cast< sal_uInt8 >(eFldType);  // Typ nachtragen
    1781           2 :         pFldP->Append( Fc2Cp( Strm().Tell() ), aFld13 );
    1782           2 :         InsertSpecialChar( *this, 0x13, 0, bIncludeEmptyPicLocation );
    1783             :     }
    1784           4 :     if (WRITEFIELD_CMD_START & nMode)
    1785             :     {
    1786           2 :         if (bUnicode)
    1787           2 :             SwWW8Writer::WriteString16(Strm(), rFldCmd, false);
    1788             :         else
    1789             :         {
    1790           0 :             SwWW8Writer::WriteString8(Strm(), rFldCmd, false,
    1791           0 :                 RTL_TEXTENCODING_MS_1252);
    1792             :         }
    1793             :         // #i43956# - write hyperlink character including
    1794             :         // attributes and corresponding binary data for certain reference fields.
    1795           2 :         bool bHandleBookmark = false;
    1796             : 
    1797           2 :         if (pFld)
    1798             :         {
    1799           0 :             if (pFld->GetTyp()->Which() == RES_GETREFFLD &&
    1800             :                 ( eFldType == ww::ePAGEREF || eFldType == ww::eREF ||
    1801             :                   eFldType == ww::eNOTEREF || eFldType == ww::eFOOTREF ))
    1802           0 :                 bHandleBookmark = true;
    1803             : 
    1804             :         }
    1805             : 
    1806           2 :         if ( bHandleBookmark )
    1807             :         {
    1808             :             // retrieve reference destination - the name of the bookmark
    1809           0 :             String aLinkStr;
    1810           0 :             const sal_uInt16 nSubType = pFld->GetSubType();
    1811           0 :             const SwGetRefField& rRFld = *(static_cast<const SwGetRefField*>(pFld));
    1812           0 :             if ( nSubType == REF_SETREFATTR ||
    1813             :                  nSubType == REF_BOOKMARK )
    1814             :             {
    1815           0 :                 aLinkStr = GetBookmarkName( nSubType, &rRFld.GetSetRefName(), 0 );
    1816             :             }
    1817           0 :             else if ( nSubType == REF_FOOTNOTE ||
    1818             :                       nSubType == REF_ENDNOTE )
    1819             :             {
    1820           0 :                 aLinkStr = GetBookmarkName( nSubType, 0, rRFld.GetSeqNo() );
    1821             :             }
    1822           0 :             else if ( nSubType == REF_SEQUENCEFLD )
    1823             :             {
    1824           0 :                 aLinkStr = pFld->GetPar2();
    1825             :             }
    1826             :             // insert hyperlink character including attributes and data.
    1827           0 :             InsertSpecialChar( *this, 0x01, &aLinkStr );
    1828             :         }
    1829             :     }
    1830           4 :     if (WRITEFIELD_CMD_END & nMode)
    1831             :     {
    1832             :         static const sal_uInt8 aFld14[2] = { 0x14, 0xff };
    1833           2 :         pFldP->Append( Fc2Cp( Strm().Tell() ), aFld14 );
    1834           2 :         pFldP->ResultAdded();
    1835           2 :         InsertSpecialChar( *this, 0x14, 0, bIncludeEmptyPicLocation );
    1836             :     }
    1837           4 :     if (WRITEFIELD_END & nMode)
    1838             :     {
    1839           2 :         String sOut;
    1840           2 :         if( pFld )
    1841           0 :             sOut = lcl_GetExpandedField(*pFld);
    1842             :         else
    1843           2 :             sOut = rFldCmd;
    1844           2 :         if( sOut.Len() )
    1845             :         {
    1846           0 :             if( bUnicode )
    1847           0 :                 SwWW8Writer::WriteString16(Strm(), sOut, false);
    1848             :             else
    1849             :             {
    1850           0 :                 SwWW8Writer::WriteString8(Strm(), sOut, false,
    1851           0 :                     RTL_TEXTENCODING_MS_1252);
    1852             :             }
    1853             : 
    1854           0 :             if (pFld)
    1855             :             {
    1856           0 :                 if (pFld->GetTyp()->Which() == RES_INPUTFLD &&
    1857             :                     eFldType == ww::eFORMTEXT)
    1858             :                 {
    1859             :                     sal_uInt8 aArr[12];
    1860           0 :                     sal_uInt8 *pArr = aArr;
    1861             : 
    1862           0 :                     if ( bWrtWW8 )
    1863             :                     {
    1864           0 :                         Set_UInt16( pArr, NS_sprm::LN_CPicLocation );
    1865           0 :                         Set_UInt32( pArr, 0x0 );
    1866             : 
    1867           0 :                         Set_UInt16( pArr, NS_sprm::LN_CFSpec );
    1868           0 :                         Set_UInt8( pArr, 1 );
    1869             : 
    1870           0 :                         Set_UInt16( pArr, NS_sprm::LN_CFNoProof );
    1871           0 :                         Set_UInt8( pArr, 1 );
    1872             :                     }
    1873             :                     else
    1874             :                     {
    1875           0 :                         Set_UInt8(pArr, 0x68); //sprmCPicLocation
    1876           0 :                         Set_UInt32(pArr, 0x0);
    1877             : 
    1878           0 :                         Set_UInt8( pArr, 117 ); //sprmCFSpec
    1879           0 :                         Set_UInt8( pArr, 1 );
    1880             :                     }
    1881           0 :                     pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr );
    1882             :                 }
    1883             :             }
    1884           2 :         }
    1885             :     }
    1886           4 :     if (WRITEFIELD_CLOSE & nMode)
    1887             :     {
    1888           2 :         sal_uInt8 aFld15[2] = { 0x15, 0x80 };
    1889             : 
    1890           2 :         if (pFld)
    1891             :         {
    1892           0 :             if (pFld->GetTyp()->Which() == RES_INPUTFLD &&
    1893             :                 eFldType == ww::eFORMTEXT)
    1894             :             {
    1895           0 :                 sal_uInt16 nSubType = pFld->GetSubType();
    1896             : 
    1897           0 :                 if (nSubType == REF_SEQUENCEFLD)
    1898           0 :                     aFld15[0] |= (0x4 << 5);
    1899             :             }
    1900             :         }
    1901             : 
    1902           2 :         pFldP->Append( Fc2Cp( Strm().Tell() ), aFld15 );
    1903           2 :         InsertSpecialChar( *this, 0x15, 0, bIncludeEmptyPicLocation );
    1904             :     }
    1905           4 : }
    1906             : 
    1907           0 : void WW8Export::StartCommentOutput(const String& rName)
    1908             : {
    1909           0 :     String sStr(FieldString(ww::eQUOTE));
    1910           0 :     sStr.AppendAscii("[");
    1911           0 :     sStr += rName;
    1912           0 :     sStr.AppendAscii("] ");
    1913           0 :     OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START);
    1914           0 : }
    1915             : 
    1916           0 : void WW8Export::EndCommentOutput(const String& rName)
    1917             : {
    1918           0 :     String sStr(rtl::OUString(" ["));
    1919           0 :     sStr += rName;
    1920           0 :     sStr.AppendAscii("] ");
    1921             :     OutputField(0, ww::eQUOTE, sStr, WRITEFIELD_CMD_END | WRITEFIELD_END |
    1922           0 :         WRITEFIELD_CLOSE);
    1923           0 : }
    1924             : 
    1925           0 : sal_uInt16 MSWordExportBase::GetId( const SwTOXType& rTOXType )
    1926             : {
    1927             :     std::vector<const SwTOXType*>::iterator it
    1928           0 :         = std::find( aTOXArr.begin(), aTOXArr.end(), &rTOXType );
    1929           0 :     if ( it != aTOXArr.end() )
    1930             :     {
    1931           0 :         return it - aTOXArr.begin();
    1932             :     }
    1933           0 :     aTOXArr.push_back( &rTOXType );
    1934           0 :     return aTOXArr.size() - 1;
    1935             : }
    1936             : 
    1937             : // return values:  1 - no PageNum,
    1938             : //                 2 - TabStop before PageNum,
    1939             : //                 3 - Text before PageNum - rTxt hold the text
    1940             : //                 4 - no Text and no TabStop before PageNum
    1941           0 : static int lcl_CheckForm( const SwForm& rForm, sal_uInt8 nLvl, String& rText )
    1942             : {
    1943           0 :     int nRet = 4;
    1944           0 :     rText.Erase();
    1945             : 
    1946             :     // #i21237#
    1947           0 :     SwFormTokens aPattern = rForm.GetPattern(nLvl);
    1948           0 :     SwFormTokens::iterator aIt = aPattern.begin();
    1949           0 :     bool bPgNumFnd = false;
    1950             :     FormTokenType eTType;
    1951             : 
    1952             :     // #i61362#
    1953           0 :     if (! aPattern.empty())
    1954             :     {
    1955             :         // #i21237#
    1956           0 :         while( ++aIt != aPattern.end() && !bPgNumFnd )
    1957             :         {
    1958           0 :             eTType = aIt->eTokenType;
    1959             : 
    1960           0 :             switch( eTType )
    1961             :             {
    1962             :             case TOKEN_PAGE_NUMS:
    1963           0 :                 bPgNumFnd = true;
    1964           0 :                 break;
    1965             : 
    1966             :             case TOKEN_TAB_STOP:
    1967           0 :                 nRet = 2;
    1968           0 :                 break;
    1969             :             case TOKEN_TEXT:
    1970           0 :                 nRet = 3;
    1971           0 :                 rText = aIt->sText.Copy( 0, 5 ); // #i21237#
    1972           0 :                 break;
    1973             : 
    1974             :             case TOKEN_LINK_START:
    1975             :             case TOKEN_LINK_END:
    1976           0 :                 break;
    1977             : 
    1978             :             default:
    1979           0 :                 nRet = 4;
    1980           0 :                 break;
    1981             :             }
    1982             :         }
    1983             : 
    1984           0 :         if( !bPgNumFnd )
    1985           0 :             nRet = 1;
    1986             :     }
    1987             : 
    1988           0 :     return nRet;
    1989             : }
    1990             : 
    1991           0 : static bool lcl_IsHyperlinked(const SwForm& rForm, sal_uInt16 nTOXLvl)
    1992             : {
    1993           0 :     bool bRes = false;
    1994           0 :     for (sal_uInt16 nI = 1; nI < nTOXLvl; ++nI)
    1995             :     {
    1996             :         // #i21237#
    1997           0 :         SwFormTokens aPattern = rForm.GetPattern(nI);
    1998             : 
    1999           0 :         if ( !aPattern.empty() )
    2000             :         {
    2001           0 :             SwFormTokens::iterator aIt = aPattern.begin();
    2002             : 
    2003             :             FormTokenType eTType;
    2004             : 
    2005             :             // #i21237#
    2006           0 :             while ( ++aIt != aPattern.end() )
    2007             :             {
    2008           0 :                 eTType = aIt->eTokenType;
    2009           0 :                 switch (eTType)
    2010             :                 {
    2011             :                 case TOKEN_LINK_START:
    2012             :                 case TOKEN_LINK_END:
    2013           0 :                     bRes = true;
    2014           0 :                 break;
    2015             :                 default:
    2016             :                     ;
    2017             :                 }
    2018             :             }
    2019             :         }
    2020           0 :     }
    2021           0 :     return bRes;
    2022             : }
    2023             : 
    2024           0 : void AttributeOutputBase::StartTOX( const SwSection& rSect )
    2025             : {
    2026           0 :     if ( const SwTOXBase* pTOX = rSect.GetTOXBase() )
    2027             :     {
    2028             :         static const sal_Char sEntryEnd[] = "\" ";
    2029             : 
    2030           0 :         ww::eField eCode = ww::eTOC;
    2031           0 :         String sStr;
    2032           0 :         switch (pTOX->GetType())
    2033             :         {
    2034             :         case TOX_INDEX:
    2035           0 :             eCode = ww::eINDEX;
    2036           0 :             sStr = FieldString(eCode);
    2037             : 
    2038           0 :             if (pTOX->GetTOXForm().IsCommaSeparated())
    2039           0 :                 sStr.AppendAscii("\\r ");
    2040             : 
    2041           0 :             if (nsSwTOIOptions::TOI_ALPHA_DELIMITTER & pTOX->GetOptions())
    2042           0 :                 sStr.AppendAscii("\\h \"A\" ");
    2043             : 
    2044             :             {
    2045           0 :                 String aFillTxt;
    2046           0 :                 for (sal_uInt8 n = 1; n <= 3; ++n)
    2047             :                 {
    2048           0 :                     String aTxt;
    2049           0 :                     int nRet = ::lcl_CheckForm(pTOX->GetTOXForm(), n, aTxt);
    2050             : 
    2051           0 :                     if( 3 == nRet )
    2052           0 :                         aFillTxt = aTxt;
    2053           0 :                     else if ((4 == nRet) || (2 == nRet))
    2054           0 :                         aFillTxt = '\t';
    2055             :                     else
    2056           0 :                         aFillTxt.Erase();
    2057           0 :                 }
    2058           0 :                 sStr.AppendAscii("\\e \"");
    2059           0 :                 sStr += aFillTxt;
    2060           0 :                 sStr.AppendAscii(sEntryEnd);
    2061             :             }
    2062           0 :             break;
    2063             : 
    2064             :         case TOX_ILLUSTRATIONS:
    2065             :         case TOX_OBJECTS:
    2066             :         case TOX_TABLES:
    2067           0 :             if (!pTOX->IsFromObjectNames())
    2068             :             {
    2069           0 :                 sStr = FieldString(eCode);
    2070             : 
    2071           0 :                 sStr.AppendAscii("\\c \"");
    2072           0 :                 sStr += pTOX->GetSequenceName();
    2073           0 :                 sStr.AppendAscii(sEntryEnd);
    2074             : 
    2075           0 :                 String aTxt;
    2076           0 :                 int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(), 1, aTxt );
    2077           0 :                 if (1 == nRet)
    2078           0 :                     sStr.AppendAscii("\\n ");
    2079           0 :                 else if( 3 == nRet || 4 == nRet )
    2080             :                 {
    2081           0 :                     sStr.AppendAscii("\\p \"");
    2082           0 :                     sStr += aTxt;
    2083           0 :                     sStr.AppendAscii(sEntryEnd);
    2084           0 :                 }
    2085             :             }
    2086           0 :             break;
    2087             : 
    2088             :         default:
    2089             :             {
    2090           0 :                 sStr = FieldString(eCode);
    2091             : 
    2092           0 :                 String sTOption;
    2093           0 :                 sal_uInt16 n, nTOXLvl = pTOX->GetLevel();
    2094           0 :                 if( !nTOXLvl )
    2095           0 :                     ++nTOXLvl;
    2096             : 
    2097           0 :                 if( nsSwTOXElement::TOX_MARK & pTOX->GetCreateType() )
    2098             :                 {
    2099           0 :                     sStr.AppendAscii( "\\f " );
    2100             : 
    2101           0 :                     if( TOX_USER == pTOX->GetType() )
    2102             :                     {
    2103           0 :                          sStr += '\"';
    2104           0 :                          sStr += (sal_Char)( 'A' + GetExport( ).GetId( *pTOX->GetTOXType() ) );
    2105           0 :                          sStr.AppendAscii( sEntryEnd );
    2106             :                     }
    2107             : 
    2108           0 :                 if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
    2109             :                 {
    2110           0 :                     const int nMinLvl = nTOXLvl;
    2111             : 
    2112           0 :                     if ( nMinLvl > 0 )
    2113             :                     {
    2114           0 :                         int nTmpLvl = nMinLvl;
    2115           0 :                         if (nTmpLvl > WW8ListManager::nMaxLevel)
    2116           0 :                             nTmpLvl = WW8ListManager::nMaxLevel;
    2117             : 
    2118           0 :                         sStr.AppendAscii( "\\o \"1-" );
    2119           0 :                         sStr += String::CreateFromInt32( nTmpLvl );
    2120           0 :                         sStr.AppendAscii(sEntryEnd);
    2121             : 
    2122             :                     }
    2123             : 
    2124             :                 }
    2125             : 
    2126             : 
    2127           0 :         if( nsSwTOXElement::TOX_OUTLINELEVEL & pTOX->GetCreateType() )
    2128             :                   {
    2129             :             // Take the TOC value of the max level to evaluate to as
    2130             :             // the starting point for the \o flag, but reduce it to the
    2131             :             // value of the highest outline level filled by a *standard*
    2132             :             // Heading 1 - 9 style because \o "Builds a table of
    2133             :             // contents from paragraphs formatted with built-in heading
    2134             :             // styles". And afterward fill in any outline styles left
    2135             :             // uncovered by that range to the \t flag
    2136             :             //
    2137             :             // i.e. for
    2138             :             // Heading 1
    2139             :             // Heading 2
    2140             :             // custom-style
    2141             :             // Heading 4
    2142             :             // output
    2143             :             // \o 1-2 \tcustom-style,3,Heading 3,4
    2144             : 
    2145             :             // Search over all the outline styles used and figure out
    2146             :             // what is the minimum outline level (if any) filled by a
    2147             :             // non-standard style for that level, i.e. ignore headline
    2148             :             // styles 1-9 and find the lowest valid outline level
    2149           0 :             sal_uInt8 nPosOfLowestNonStandardLvl = MAXLEVEL;
    2150           0 :             const SwTxtFmtColls& rColls = *GetExport().pDoc->GetTxtFmtColls();
    2151           0 :             for( n = rColls.size(); n; )
    2152             :                       {
    2153           0 :             const SwTxtFmtColl* pColl = rColls[ --n ];
    2154           0 :             sal_uInt16 nPoolId = pColl->GetPoolFmtId();
    2155           0 :             if (
    2156             :                 //Is a Non-Standard Outline Style
    2157             :                 (RES_POOLCOLL_HEADLINE1 > nPoolId || RES_POOLCOLL_HEADLINE9 < nPoolId) &&
    2158             :                 //Has a valid outline level
    2159           0 :                 (pColl->IsAssignedToListLevelOfOutlineStyle()) &&
    2160             :                 // Is less than the lowest known non-standard level
    2161           0 :                 (pColl->GetAssignedOutlineStyleLevel() < nPosOfLowestNonStandardLvl)
    2162             :                             )
    2163             :                           {
    2164           0 :                               nPosOfLowestNonStandardLvl = ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
    2165             :                           }
    2166             :                       }
    2167             : 
    2168           0 :             sal_uInt8 nMaxMSAutoEvaluate = nPosOfLowestNonStandardLvl < nTOXLvl ? nPosOfLowestNonStandardLvl : (sal_uInt8)nTOXLvl;
    2169             : 
    2170             :             //output \o 1-X where X is the highest normal outline style to be included in the toc
    2171           0 :             if ( nMaxMSAutoEvaluate )
    2172             :               {
    2173           0 :             if (nMaxMSAutoEvaluate > WW8ListManager::nMaxLevel)
    2174           0 :               nMaxMSAutoEvaluate = WW8ListManager::nMaxLevel;
    2175             : 
    2176           0 :             sStr.AppendAscii( "\\o \"1-" );
    2177           0 :             sStr += String::CreateFromInt32( nMaxMSAutoEvaluate );
    2178           0 :             sStr.AppendAscii(sEntryEnd);
    2179             :                       }
    2180             : 
    2181             :             //collect up any other styles in the writer TOC which will
    2182             :             //not already appear in the MS TOC and place then into the
    2183             :             //\t option
    2184           0 :             if( nMaxMSAutoEvaluate < nTOXLvl )
    2185             :                       {
    2186             :             // collect this templates into the \t otion
    2187           0 :             for( n = rColls.size(); n;)
    2188             :                           {
    2189           0 :                 const SwTxtFmtColl* pColl = rColls[ --n ];
    2190           0 :                 if (!pColl->IsAssignedToListLevelOfOutlineStyle())
    2191           0 :                   continue;
    2192           0 :                 sal_uInt8 nTestLvl =  ::sal::static_int_cast<sal_uInt8>(pColl->GetAssignedOutlineStyleLevel());
    2193           0 :                 if (nTestLvl < nTOXLvl && nTestLvl >= nMaxMSAutoEvaluate)
    2194             :                   {
    2195           0 :                 if( sTOption.Len() )
    2196           0 :                   sTOption += ',';
    2197           0 :                 (( sTOption += pColl->GetName() ) += ',' )
    2198           0 :                   += String::CreateFromInt32( nTestLvl + 1 );
    2199             :                   }
    2200             :               }
    2201             :               }
    2202             :                   }
    2203             : 
    2204           0 :                 if( nsSwTOXElement::TOX_TEMPLATE & pTOX->GetCreateType() )
    2205             :                     // #i99641# - Consider additional styles regardless of TOX-outlinelevel
    2206           0 :                     for( n = 0; n < MAXLEVEL; ++n )
    2207             :                     {
    2208           0 :                         const String& rStyles = pTOX->GetStyleNames( n );
    2209           0 :                         if( rStyles.Len() )
    2210             :                         {
    2211           0 :                             xub_StrLen nPos = 0;
    2212           0 :                             String sLvl = rtl::OUString(',');
    2213           0 :                             sLvl += String::CreateFromInt32( n + 1 );
    2214           0 :                             do {
    2215             :                                 String sStyle( rStyles.GetToken( 0,
    2216           0 :                                             TOX_STYLE_DELIMITER, nPos ));
    2217           0 :                                 if( sStyle.Len() )
    2218             :                                 {
    2219           0 :                                     SwTxtFmtColl* pColl = GetExport().pDoc->FindTxtFmtCollByName(sStyle);
    2220           0 :                                     if (!pColl || !pColl->IsAssignedToListLevelOfOutlineStyle() || pColl->GetAssignedOutlineStyleLevel() < nTOXLvl)
    2221             :                                     {
    2222           0 :                                         if( sTOption.Len() )
    2223           0 :                                             sTOption += ',';
    2224           0 :                                         ( sTOption += sStyle ) += sLvl;
    2225             :                                     }
    2226           0 :                                 }
    2227           0 :                             } while( STRING_NOTFOUND != nPos );
    2228             :                         }
    2229             :                     }
    2230             : 
    2231             :                 {
    2232           0 :                     String aFillTxt;
    2233           0 :                     sal_uInt8 nNoPgStt = MAXLEVEL, nNoPgEnd = MAXLEVEL;
    2234           0 :                     bool bFirstFillTxt = true, bOnlyText = true;
    2235           0 :                     for( n = 0; n < nTOXLvl; ++n )
    2236             :                     {
    2237           0 :                         String aTxt;
    2238           0 :                         int nRet = ::lcl_CheckForm( pTOX->GetTOXForm(),
    2239           0 :                                                     static_cast< sal_uInt8 >(n+1), aTxt );
    2240           0 :                         if( 1 == nRet )
    2241             :                         {
    2242           0 :                             bOnlyText = false;
    2243           0 :                             if( MAXLEVEL == nNoPgStt )
    2244           0 :                                 nNoPgStt = static_cast< sal_uInt8 >(n+1);
    2245             :                         }
    2246             :                         else
    2247             :                         {
    2248           0 :                             if( MAXLEVEL != nNoPgStt &&
    2249             :                                 MAXLEVEL == nNoPgEnd )
    2250           0 :                                 nNoPgEnd = sal_uInt8(n);
    2251             : 
    2252           0 :                             bOnlyText = bOnlyText && 3 == nRet;
    2253           0 :                             if( 3 == nRet || 4 == nRet )
    2254             :                             {
    2255           0 :                                 if( bFirstFillTxt )
    2256           0 :                                     aFillTxt = aTxt;
    2257           0 :                                 else if( aFillTxt != aTxt )
    2258           0 :                                     aFillTxt.Erase();
    2259           0 :                                 bFirstFillTxt = false;
    2260             :                             }
    2261             :                         }
    2262           0 :                     }
    2263           0 :                     if( MAXLEVEL != nNoPgStt )
    2264             :                     {
    2265           0 :                         if (WW8ListManager::nMaxLevel < nNoPgEnd)
    2266           0 :                             nNoPgEnd = WW8ListManager::nMaxLevel;
    2267           0 :                         sStr.AppendAscii( "\\n " );
    2268           0 :                         sStr += String::CreateFromInt32( nNoPgStt );
    2269           0 :                         sStr += '-';
    2270           0 :                         sStr += String::CreateFromInt32( nNoPgEnd  );
    2271           0 :                         sStr += ' ';
    2272             :                     }
    2273           0 :                     if( bOnlyText )
    2274             :                     {
    2275           0 :                         sStr.AppendAscii( "\\p \"" );
    2276           0 :                         sStr += aFillTxt;
    2277           0 :                         sStr.AppendAscii(sEntryEnd);
    2278           0 :                     }
    2279             :                 }
    2280             : 
    2281           0 :                 if( sTOption.Len() )
    2282             :                 {
    2283           0 :                     sStr.AppendAscii( "\\t \"" );
    2284           0 :                     sStr += sTOption;
    2285           0 :                     sStr.AppendAscii(sEntryEnd);
    2286             :                 }
    2287             : 
    2288           0 :                 if (lcl_IsHyperlinked(pTOX->GetTOXForm(), nTOXLvl))
    2289           0 :                     sStr.AppendAscii("\\h");
    2290             :             }
    2291           0 :             break;
    2292             :             }
    2293             :         }
    2294             : 
    2295           0 :         if( sStr.Len() )
    2296             :         {
    2297           0 :             GetExport( ).bInWriteTOX = true;
    2298           0 :             GetExport( ).OutputField( 0, eCode, sStr, WRITEFIELD_START | WRITEFIELD_CMD_START |
    2299           0 :                 WRITEFIELD_CMD_END );
    2300           0 :         }
    2301             :     }
    2302             : 
    2303           0 :     GetExport( ).bStartTOX = false;
    2304           0 : }
    2305             : 
    2306           0 : void AttributeOutputBase::EndTOX( const SwSection& rSect )
    2307             : {
    2308           0 :     const SwTOXBase* pTOX = rSect.GetTOXBase();
    2309           0 :     if ( pTOX )
    2310             :     {
    2311           0 :         ww::eField eCode = TOX_INDEX == pTOX->GetType() ? ww::eINDEX : ww::eTOC;
    2312           0 :         GetExport( ).OutputField( 0, eCode, aEmptyStr, WRITEFIELD_CLOSE );
    2313             :     }
    2314           0 :     GetExport( ).bInWriteTOX = false;
    2315           0 : }
    2316             : 
    2317           0 : bool MSWordExportBase::GetNumberFmt(const SwField& rFld, String& rStr)
    2318             : {
    2319             :     // Returns a date or time format string by using the US NfKeywordTable
    2320           0 :     bool bHasFmt = false;
    2321           0 :     SvNumberFormatter* pNFmtr = pDoc->GetNumberFormatter();
    2322           0 :     sal_uInt32 nFmtIdx = rFld.GetFormat();
    2323           0 :     const SvNumberformat* pNumFmt = pNFmtr->GetEntry( nFmtIdx );
    2324           0 :     if( pNumFmt )
    2325             :     {
    2326           0 :         sal_uInt16 nLng = rFld.GetLanguage();
    2327             :         LocaleDataWrapper aLocDat(comphelper::getComponentContext(pNFmtr->GetServiceManager()),
    2328           0 :                                   LanguageTag(nLng));
    2329             : 
    2330           0 :         String sFmt(pNumFmt->GetMappedFormatstring(GetNfKeywordTable(),
    2331           0 :             aLocDat));
    2332             : 
    2333           0 :         if (sFmt.Len())
    2334             :         {
    2335           0 :             sw::ms::SwapQuotesInField(sFmt);
    2336             : 
    2337           0 :             rStr.AppendAscii( "\\@\"" );
    2338           0 :             rStr += sFmt;
    2339           0 :             rStr.AppendAscii( "\" " );
    2340           0 :             bHasFmt = true;
    2341           0 :         }
    2342             :     }
    2343           0 :     return bHasFmt;
    2344             : }
    2345             : 
    2346           0 : void AttributeOutputBase::GetNumberPara( String& rStr, const SwField& rFld )
    2347             : {
    2348           0 :     switch(rFld.GetFormat())
    2349             :     {
    2350             :         case SVX_NUM_CHARS_UPPER_LETTER:
    2351             :         case SVX_NUM_CHARS_UPPER_LETTER_N:
    2352           0 :             rStr.AppendAscii( "\\*ALPHABETIC ");
    2353           0 :             break;
    2354             :         case SVX_NUM_CHARS_LOWER_LETTER:
    2355             :         case SVX_NUM_CHARS_LOWER_LETTER_N:
    2356           0 :             rStr.AppendAscii("\\*alphabetic ");
    2357           0 :             break;
    2358             :         case SVX_NUM_ROMAN_UPPER:
    2359           0 :             rStr.AppendAscii("\\*ROMAN ");
    2360           0 :             break;
    2361             :         case SVX_NUM_ROMAN_LOWER:
    2362           0 :             rStr.AppendAscii("\\*roman ");
    2363           0 :             break;
    2364             :         default:
    2365             :             OSL_ENSURE(rFld.GetFormat() == SVX_NUM_ARABIC,
    2366             :                 "Unknown numbering type exported as default\n");
    2367             :         case SVX_NUM_ARABIC:
    2368           0 :             rStr.AppendAscii("\\*Arabic ");
    2369           0 :             break;
    2370             :         case SVX_NUM_PAGEDESC:
    2371             :             //Nothing, use word's default
    2372           0 :             break;
    2373             :     }
    2374           0 : }
    2375             : 
    2376           0 : void WW8Export::WritePostItBegin( ww::bytes* pOut )
    2377             : {
    2378             :     sal_uInt8 aArr[ 3 ];
    2379           0 :     sal_uInt8* pArr = aArr;
    2380             : 
    2381             :     // sprmCFSpec true
    2382           0 :     if( bWrtWW8 )
    2383           0 :         Set_UInt16( pArr, NS_sprm::LN_CFSpec );
    2384             :     else
    2385           0 :         Set_UInt8( pArr, 117 ); //sprmCFSpec
    2386           0 :     Set_UInt8( pArr, 1 );
    2387             : 
    2388           0 :     pChpPlc->AppendFkpEntry( Strm().Tell() );
    2389           0 :     WriteChar( 0x05 );              // Annotation reference
    2390             : 
    2391           0 :     if( pOut )
    2392           0 :         pOut->insert( pOut->end(), aArr, pArr );
    2393             :     else
    2394           0 :         pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr );
    2395           0 : }
    2396             : 
    2397           6 : String FieldString(ww::eField eIndex)
    2398             : {
    2399           6 :     String sRet(rtl::OUString("  "));
    2400           6 :     if (const char *pField = ww::GetEnglishFieldName(eIndex))
    2401           6 :         sRet.InsertAscii(pField, 1);
    2402           6 :     return sRet;
    2403             : }
    2404             : 
    2405           0 : void WW8AttributeOutput::HiddenField( const SwField& rFld )
    2406             : {
    2407           0 :     String sExpand(rFld.GetPar2());
    2408             : 
    2409             :     //replace LF 0x0A with VT 0x0B
    2410           0 :     sExpand.SearchAndReplaceAll(0x0A, 0x0B);
    2411           0 :     m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell());
    2412           0 :     if (m_rWW8Export.IsUnicode())
    2413             :     {
    2414           0 :         SwWW8Writer::WriteString16(m_rWW8Export.Strm(), sExpand, false);
    2415             :         static sal_uInt8 aArr[] =
    2416             :         {
    2417             :             0x3C, 0x08, 0x1
    2418             :         };
    2419           0 :         m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr);
    2420             :     }
    2421             :     else
    2422             :     {
    2423           0 :         SwWW8Writer::WriteString8(m_rWW8Export.Strm(), sExpand, false,
    2424           0 :             RTL_TEXTENCODING_MS_1252);
    2425             :         static sal_uInt8 aArr[] =
    2426             :         {
    2427             :             92, 0x1
    2428             :         };
    2429           0 :         m_rWW8Export.pChpPlc->AppendFkpEntry(m_rWW8Export.Strm().Tell(), sizeof(aArr), aArr);
    2430           0 :     }
    2431           0 : }
    2432             : 
    2433           0 : void WW8AttributeOutput::SetField( const SwField& rFld, ww::eField eType, const String& rCmd )
    2434             : {
    2435           0 :     const SwSetExpField* pSet=(const SwSetExpField*)(&rFld);
    2436           0 :     const String &rVar = pSet->GetPar2();
    2437             : 
    2438           0 :     sal_uLong nFrom = m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell());
    2439             : 
    2440           0 :     GetExport().OutputField(&rFld, eType, rCmd, WRITEFIELD_START |
    2441           0 :         WRITEFIELD_CMD_START | WRITEFIELD_CMD_END);
    2442             : 
    2443             :     /*
    2444             :     Is there a bookmark at the start position of this field, if so
    2445             :     move it to the 0x14 of the result of the field.  This is what word
    2446             :     does. MoveFieldMarks moves any bookmarks at this position to
    2447             :     the beginning of the field result, and marks the bookmark as a
    2448             :     fieldbookmark which is to be ended before the field end mark
    2449             :     instead of after it like a normal bookmark.
    2450             :     */
    2451           0 :     m_rWW8Export.MoveFieldMarks(nFrom,m_rWW8Export.Fc2Cp(m_rWW8Export.Strm().Tell()));
    2452             : 
    2453           0 :     if (rVar.Len())
    2454             :     {
    2455           0 :         if (m_rWW8Export.IsUnicode())
    2456           0 :             SwWW8Writer::WriteString16(m_rWW8Export.Strm(), rVar, false);
    2457             :         else
    2458             :         {
    2459           0 :             SwWW8Writer::WriteString8(m_rWW8Export.Strm(), rVar, false,
    2460           0 :                 RTL_TEXTENCODING_MS_1252);
    2461             :         }
    2462             :     }
    2463           0 :     GetExport().OutputField(&rFld, eType, rCmd, WRITEFIELD_CLOSE);
    2464           0 : }
    2465             : 
    2466           0 : void WW8AttributeOutput::PostitField( const SwField* pFld )
    2467             : {
    2468           0 :     const SwPostItField *pPFld = (const SwPostItField*)pFld;
    2469           0 :     m_rWW8Export.pAtn->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), pPFld );
    2470           0 :     m_rWW8Export.WritePostItBegin( m_rWW8Export.pO );
    2471           0 : }
    2472             : 
    2473           0 : bool WW8AttributeOutput::DropdownField( const SwField* pFld )
    2474             : {
    2475           0 :     bool bExpand = true;
    2476           0 :     if ( m_rWW8Export.bWrtWW8 )
    2477             :     {
    2478           0 :         const SwDropDownField& rFld2 = *(SwDropDownField*)pFld;
    2479             :         uno::Sequence<rtl::OUString> aItems =
    2480           0 :             rFld2.GetItemSequence();
    2481           0 :         GetExport().DoComboBox(rFld2.GetName(),
    2482           0 :                            rFld2.GetHelp(),
    2483           0 :                            rFld2.GetToolTip(),
    2484           0 :                            rFld2.GetSelectedItem(), aItems);
    2485           0 :         bExpand = false;
    2486             :     }
    2487           0 :     return bExpand;
    2488             : }
    2489             : 
    2490           0 : void WW8AttributeOutput::RefField( const SwField &rFld, const String &rRef)
    2491             : {
    2492           0 :     String sStr( FieldString( ww::eREF ) );
    2493           0 :     sStr.AppendAscii( "\"" );
    2494           0 :     sStr += rRef;
    2495           0 :     sStr.AppendAscii( "\" " );
    2496             :     m_rWW8Export.OutputField( &rFld, ww::eREF, sStr, WRITEFIELD_START |
    2497           0 :         WRITEFIELD_CMD_START | WRITEFIELD_CMD_END );
    2498           0 :     String sVar = lcl_GetExpandedField( rFld );
    2499           0 :     if ( sVar.Len() )
    2500             :     {
    2501           0 :         if ( m_rWW8Export.IsUnicode() )
    2502           0 :             SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sVar, false );
    2503             :         else
    2504             :         {
    2505           0 :             SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sVar, false,
    2506           0 :                 RTL_TEXTENCODING_MS_1252 );
    2507             :         }
    2508             :     }
    2509           0 :     m_rWW8Export.OutputField( &rFld, ww::eREF, sStr, WRITEFIELD_CLOSE );
    2510           0 : }
    2511             : 
    2512           0 : void WW8AttributeOutput::WriteExpand( const SwField* pFld )
    2513             : {
    2514           0 :     String sExpand( lcl_GetExpandedField( *pFld ) );
    2515           0 :     if ( m_rWW8Export.IsUnicode() )
    2516           0 :         SwWW8Writer::WriteString16( m_rWW8Export.Strm(), sExpand, false );
    2517             :     else
    2518             :     {
    2519           0 :         SwWW8Writer::WriteString8( m_rWW8Export.Strm(), sExpand, false,
    2520           0 :             RTL_TEXTENCODING_MS_1252 );
    2521           0 :     }
    2522           0 : }
    2523             : 
    2524           4 : void AttributeOutputBase::TextField( const SwFmtFld& rField )
    2525             : {
    2526           4 :     const SwField* pFld = rField.GetFld();
    2527           4 :     String sStr;        // fuer optionale Parameter
    2528           4 :     bool bWriteExpand = false;
    2529           4 :     sal_uInt16 nSubType = pFld->GetSubType();
    2530             : 
    2531           4 :     switch (pFld->GetTyp()->Which())
    2532             :     {
    2533             :     case RES_GETEXPFLD:
    2534           0 :         if (nSubType == nsSwGetSetExpType::GSE_STRING)
    2535             :         {
    2536           0 :             const SwGetExpField *pGet=(const SwGetExpField*)(pFld);
    2537           0 :             RefField( *pGet, pGet->GetFormula() );
    2538             :         }
    2539             :         else
    2540           0 :             bWriteExpand = true;
    2541           0 :         break;
    2542             :     case RES_SETEXPFLD:
    2543           0 :         if (nsSwGetSetExpType::GSE_SEQ == nSubType)
    2544             :         {
    2545           0 :             sStr = FieldString(ww::eSEQ);
    2546           0 :             sStr.AppendAscii("\"");
    2547           0 :             sStr += pFld->GetTyp()->GetName();
    2548           0 :             sStr.AppendAscii( "\" " );
    2549             : 
    2550           0 :             GetNumberPara( sStr, *pFld );
    2551           0 :             GetExport().OutputField(pFld, ww::eSEQ, sStr);
    2552             :         }
    2553           0 :         else if (nSubType & nsSwGetSetExpType::GSE_STRING)
    2554             :         {
    2555           0 :             bool bShowAsWell = false;
    2556             :             ww::eField eFieldNo;
    2557           0 :             const SwSetExpField *pSet=(const SwSetExpField*)(pFld);
    2558           0 :             const String &rVar = pSet->GetPar2();
    2559           0 :             if (pSet->GetInputFlag())
    2560             :             {
    2561           0 :                 sStr = FieldString(ww::eASK);
    2562           0 :                 sStr.AppendAscii("\"");
    2563           0 :                 sStr += pSet->GetPar1();
    2564           0 :                 sStr.AppendAscii( "\" " );
    2565           0 :                 sStr += pSet->GetPromptText();
    2566           0 :                 sStr.AppendAscii( " \\d " );
    2567           0 :                 sStr += rVar;
    2568           0 :                 eFieldNo = ww::eASK;
    2569             :             }
    2570             :             else
    2571             :             {
    2572           0 :                 sStr = FieldString(ww::eSET);
    2573           0 :                 sStr += pSet->GetPar1();
    2574           0 :                 sStr.AppendAscii(" \"");
    2575           0 :                 sStr += rVar;
    2576           0 :                 sStr.AppendAscii("\" ");
    2577           0 :                 eFieldNo = ww::eSET;
    2578           0 :                 bShowAsWell = (nSubType & nsSwExtendedSubType::SUB_INVISIBLE) ? false : true;
    2579             :             }
    2580             : 
    2581           0 :             SetField( *pFld, eFieldNo, sStr );
    2582             : 
    2583           0 :             if (bShowAsWell)
    2584           0 :                 RefField( *pSet, pSet->GetPar1() );
    2585             :         }
    2586             :         else
    2587           0 :             bWriteExpand = true;
    2588           0 :         break;
    2589             :     case RES_PAGENUMBERFLD:
    2590           0 :         sStr = FieldString(ww::ePAGE);
    2591           0 :         GetNumberPara(sStr, *pFld);
    2592           0 :         GetExport().OutputField(pFld, ww::ePAGE, sStr);
    2593           0 :         break;
    2594             :     case RES_FILENAMEFLD:
    2595           0 :         sStr = FieldString(ww::eFILENAME);
    2596           0 :         if (pFld->GetFormat() == FF_PATHNAME)
    2597           0 :             sStr.AppendAscii("\\p ");
    2598           0 :         GetExport().OutputField(pFld, ww::eFILENAME, sStr);
    2599           0 :         break;
    2600             :     case RES_DBNAMEFLD:
    2601             :         {
    2602           0 :             sStr = FieldString(ww::eDATABASE);
    2603           0 :             SwDBData aData = GetExport().pDoc->GetDBData();
    2604           0 :             sStr += String(aData.sDataSource);
    2605           0 :             sStr += DB_DELIM;
    2606           0 :             sStr += String(aData.sCommand);
    2607           0 :             GetExport().OutputField(pFld, ww::eDATABASE, sStr);
    2608             :         }
    2609           0 :         break;
    2610             :     case RES_AUTHORFLD:
    2611             :         {
    2612             :             ww::eField eFld =
    2613           0 :                 (AF_SHORTCUT & pFld->GetFormat() ? ww::eUSERINITIALS : ww::eUSERNAME);
    2614           0 :             GetExport().OutputField(pFld, eFld, FieldString(eFld));
    2615             :         }
    2616           0 :         break;
    2617             :     case RES_TEMPLNAMEFLD:
    2618           0 :         GetExport().OutputField(pFld, ww::eTEMPLATE, FieldString(ww::eTEMPLATE));
    2619           0 :         break;
    2620             :     case RES_DOCINFOFLD:    // Last printed, last edited,...
    2621           0 :         if( DI_SUB_FIXED & nSubType )
    2622           0 :             bWriteExpand = true;
    2623             :         else
    2624             :         {
    2625           0 :             ww::eField eFld(ww::eNONE);
    2626           0 :             switch (0xff & nSubType)
    2627             :             {
    2628             :                 case DI_TITEL:
    2629           0 :                     eFld = ww::eTITLE;
    2630           0 :                     break;
    2631             :                 case DI_THEMA:
    2632           0 :                     eFld = ww::eSUBJECT;
    2633           0 :                     break;
    2634             :                 case DI_KEYS:
    2635           0 :                     eFld = ww::eKEYWORDS;
    2636           0 :                     break;
    2637             :                 case DI_COMMENT:
    2638           0 :                     eFld = ww::eCOMMENTS;
    2639           0 :                     break;
    2640             :                 case DI_DOCNO:
    2641           0 :                     eFld = ww::eREVNUM;
    2642           0 :                     break;
    2643             :                 case DI_CREATE:
    2644           0 :                     if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
    2645           0 :                         eFld = ww::eAUTHOR;
    2646           0 :                     else if (GetExport().GetNumberFmt(*pFld, sStr))
    2647           0 :                         eFld = ww::eCREATEDATE;
    2648           0 :                     break;
    2649             : 
    2650             :                 case DI_CHANGE:
    2651           0 :                     if (DI_SUB_AUTHOR == (nSubType & DI_SUB_MASK))
    2652           0 :                         eFld = ww::eLASTSAVEDBY;
    2653           0 :                     else if (GetExport().GetNumberFmt(*pFld, sStr))
    2654           0 :                         eFld = ww::eSAVEDATE;
    2655           0 :                     break;
    2656             : 
    2657             :                 case DI_PRINT:
    2658           0 :                     if (DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK) &&
    2659           0 :                         GetExport().GetNumberFmt(*pFld, sStr))
    2660           0 :                         eFld = ww::ePRINTDATE;
    2661           0 :                     break;
    2662             :                 case DI_EDIT:
    2663           0 :                     if( DI_SUB_AUTHOR != (nSubType & DI_SUB_MASK ) &&
    2664           0 :                         GetExport().GetNumberFmt( *pFld, sStr ))
    2665           0 :                         eFld = ww::eSAVEDATE;
    2666           0 :                     break;
    2667             :                 case DI_CUSTOM:
    2668           0 :                     eFld = ww::eDOCPROPERTY;
    2669             :                     {
    2670           0 :                         rtl::OUString sQuotes('\"');
    2671             :                         const SwDocInfoField * pDocInfoField =
    2672           0 :                         dynamic_cast<const SwDocInfoField *> (pFld);
    2673             : 
    2674           0 :                         if (pDocInfoField != NULL)
    2675             :                         {
    2676           0 :                             String sFieldname = pDocInfoField->GetFieldName();
    2677           0 :                             xub_StrLen nIndex = sFieldname.Search(':');
    2678             : 
    2679           0 :                             if (nIndex != sFieldname.Len())
    2680           0 :                                 sFieldname = sFieldname.Copy(nIndex + 1);
    2681             : 
    2682           0 :                             sStr.Insert(sQuotes);
    2683           0 :                             sStr.Insert(sFieldname);
    2684           0 :                             sStr.Insert(sQuotes);
    2685           0 :                         }
    2686             :                     }
    2687           0 :                     break;
    2688             :                 default:
    2689           0 :                     break;
    2690             :             }
    2691             : 
    2692           0 :             if (eFld != ww::eNONE)
    2693             :             {
    2694           0 :                 sStr.Insert(FieldString(eFld), 0);
    2695           0 :                 GetExport().OutputField(pFld, eFld, sStr);
    2696             :             }
    2697             :             else
    2698           0 :                 bWriteExpand = true;
    2699             :         }
    2700           0 :         break;
    2701             :     case RES_DATETIMEFLD:
    2702           0 :         if (FIXEDFLD & nSubType || !GetExport().GetNumberFmt(*pFld, sStr))
    2703           0 :             bWriteExpand = true;
    2704             :         else
    2705             :         {
    2706           0 :             ww::eField eFld = (DATEFLD & nSubType) ? ww::eDATE : ww::eTIME;
    2707           0 :             sStr.Insert(FieldString(eFld), 0);
    2708           0 :             GetExport().OutputField(pFld, eFld, sStr);
    2709             :         }
    2710           0 :         break;
    2711             :     case RES_DOCSTATFLD:
    2712             :         {
    2713           0 :             ww::eField eFld = ww::eNONE;
    2714             : 
    2715           0 :             switch (nSubType)
    2716             :             {
    2717             :                 case DS_PAGE:
    2718           0 :                     eFld = ww::eNUMPAGE;
    2719           0 :                     break;
    2720             :                 case DS_WORD:
    2721           0 :                     eFld = ww::eNUMWORDS;
    2722           0 :                     break;
    2723             :                 case DS_CHAR:
    2724           0 :                     eFld = ww::eNUMCHARS;
    2725           0 :                     break;
    2726             :             }
    2727             : 
    2728           0 :             if (eFld != ww::eNONE)
    2729             :             {
    2730           0 :                 sStr = FieldString(eFld);
    2731           0 :                 GetNumberPara(sStr, *pFld);
    2732           0 :                 GetExport().OutputField(pFld, eFld, sStr);
    2733             :             }
    2734             :             else
    2735           0 :                 bWriteExpand = true;
    2736             :         }
    2737           0 :         break;
    2738             :     case RES_EXTUSERFLD:
    2739             :         {
    2740           0 :             ww::eField eFld = ww::eNONE;
    2741           0 :             switch (0xFF & nSubType)
    2742             :             {
    2743             :                 case EU_FIRSTNAME:
    2744             :                 case EU_NAME:
    2745           0 :                     eFld = ww::eUSERNAME;
    2746           0 :                     break;
    2747             :                 case EU_SHORTCUT:
    2748           0 :                     eFld = ww::eUSERINITIALS;
    2749           0 :                     break;
    2750             :                 case EU_STREET:
    2751             :                 case EU_COUNTRY:
    2752             :                 case EU_ZIP:
    2753             :                 case EU_CITY:
    2754           0 :                     eFld = ww::eUSERADDRESS;
    2755           0 :                     break;
    2756             :             }
    2757             : 
    2758           0 :             if (eFld != ww::eNONE)
    2759             :             {
    2760           0 :                 sStr = FieldString(eFld);
    2761           0 :                 GetExport().OutputField(pFld, eFld, sStr);
    2762             :             }
    2763             :             else
    2764           0 :                 bWriteExpand = true;
    2765             :         }
    2766           0 :         break;
    2767             :     case RES_POSTITFLD:
    2768             :         //Sadly only possible for word in main document text
    2769           4 :         if (GetExport().nTxtTyp == TXT_MAINTEXT)
    2770             :         {
    2771           4 :             PostitField( pFld );
    2772             :         }
    2773           4 :         break;
    2774             :     case RES_INPUTFLD:
    2775             :         {
    2776             :             const SwInputField * pInputField =
    2777           0 :                 dynamic_cast<const SwInputField *>(pFld);
    2778             : 
    2779           0 :             if (pInputField->isFormField())
    2780           0 :                 GetExport().DoFormText(pInputField);
    2781             :             else
    2782             :             {
    2783           0 :                 sStr = FieldString(ww::eFILLIN);
    2784             : 
    2785           0 :                 sStr.AppendAscii("\"");
    2786           0 :                 sStr += pFld->GetPar2();
    2787           0 :                 sStr += '\"';
    2788             : 
    2789           0 :                 GetExport().OutputField(pFld, ww::eFILLIN, sStr);
    2790             :             }
    2791             :         }
    2792           0 :         break;
    2793             :     case RES_GETREFFLD:
    2794             :         {
    2795           0 :             ww::eField eFld = ww::eNONE;
    2796           0 :             const SwGetRefField& rRFld = *(SwGetRefField*)pFld;
    2797           0 :             switch (nSubType)
    2798             :             {
    2799             :                 case REF_SETREFATTR:
    2800             :                 case REF_BOOKMARK:
    2801           0 :                     switch (pFld->GetFormat())
    2802             :                     {
    2803             :                         case REF_PAGE_PGDESC:
    2804             :                         case REF_PAGE:
    2805           0 :                             eFld = ww::ePAGEREF;
    2806           0 :                             break;
    2807             :                         default:
    2808           0 :                             eFld = ww::eREF;
    2809           0 :                             break;
    2810             :                     }
    2811           0 :                     sStr = FieldString(eFld);
    2812           0 :                     sStr += GetExport().GetBookmarkName(nSubType,
    2813           0 :                         &rRFld.GetSetRefName(), 0);
    2814           0 :                     switch (pFld->GetFormat())
    2815             :                     {
    2816             :                         case REF_NUMBER:
    2817           0 :                             sStr.AppendAscii(" \\r");
    2818           0 :                             break;
    2819             :                         case REF_NUMBER_NO_CONTEXT:
    2820           0 :                             sStr.AppendAscii(" \\n");
    2821           0 :                             break;
    2822             :                         case REF_NUMBER_FULL_CONTEXT:
    2823           0 :                             sStr.AppendAscii(" \\w");
    2824           0 :                             break;
    2825             :                     }
    2826           0 :                     break;
    2827             :                 case REF_FOOTNOTE:
    2828             :                 case REF_ENDNOTE:
    2829           0 :                     switch (pFld->GetFormat())
    2830             :                     {
    2831             :                         case REF_PAGE_PGDESC:
    2832             :                         case REF_PAGE:
    2833           0 :                             eFld = ww::ePAGEREF;
    2834           0 :                             break;
    2835             :                         case REF_UPDOWN:
    2836           0 :                             eFld = ww::eREF;
    2837           0 :                             break;
    2838             :                         default:
    2839             :                             eFld =
    2840           0 :                                 REF_ENDNOTE == nSubType ? ww::eNOTEREF : ww::eFOOTREF;
    2841           0 :                             break;
    2842             :                     }
    2843           0 :                     sStr = FieldString(eFld);
    2844           0 :                     sStr += GetExport().GetBookmarkName(nSubType, 0,
    2845           0 :                         rRFld.GetSeqNo());
    2846           0 :                     break;
    2847             :             }
    2848             : 
    2849           0 :             if (eFld != ww::eNONE)
    2850             :             {
    2851           0 :                 switch (pFld->GetFormat())
    2852             :                 {
    2853             :                     case REF_UPDOWN:
    2854           0 :                         sStr.AppendAscii(" \\p");
    2855           0 :                         break;
    2856             :                     case REF_CHAPTER:
    2857           0 :                         sStr.AppendAscii(" \\n");
    2858           0 :                         break;
    2859             :                     default:
    2860           0 :                         break;
    2861             :                 }
    2862           0 :                 sStr.AppendAscii(" \\h ");       // insert hyperlink
    2863           0 :                 GetExport().OutputField(pFld, eFld, sStr);
    2864             :             }
    2865             :             else
    2866           0 :                 bWriteExpand = true;
    2867             :         }
    2868           0 :         break;
    2869             :     case RES_COMBINED_CHARS:
    2870             :         {
    2871             :         /*
    2872             :         We need a font size to fill in the defaults, if these are overridden
    2873             :         (as they generally are) by character properties then those properties
    2874             :         win.
    2875             : 
    2876             :         The fontsize that is used in MS for determing the defaults is always
    2877             :         the CJK fontsize even if the text is not in that language, in OOo the
    2878             :         largest fontsize used in the field is the one we should take, but
    2879             :         whatever we do, word will actually render using the fontsize set for
    2880             :         CJK text. Nevertheless we attempt to guess whether the script is in
    2881             :         asian or western text based up on the first character and use the
    2882             :         font size of that script as our default.
    2883             :         */
    2884             :         sal_uInt16 nScript;
    2885           0 :         if( pBreakIt->GetBreakIter().is() )
    2886           0 :             nScript = pBreakIt->GetBreakIter()->getScriptType( pFld->GetPar1(), 0);
    2887             :         else
    2888           0 :             nScript = i18n::ScriptType::ASIAN;
    2889             : 
    2890           0 :         long nHeight = ((SvxFontHeightItem&)(GetExport().GetItem(
    2891           0 :             GetWhichOfScript(RES_CHRATR_FONTSIZE,nScript)))).GetHeight();;
    2892             : 
    2893           0 :         nHeight = (nHeight + 10) / 20; //Font Size in points;
    2894             : 
    2895             :         /*
    2896             :         Divide the combined char string into its up and down part. Get the
    2897             :         font size and fill in the defaults as up == half the font size and
    2898             :         down == a fifth the font size
    2899             :         */
    2900           0 :         xub_StrLen nAbove = (pFld->GetPar1().getLength()+1)/2;
    2901           0 :         sStr = FieldString(ww::eEQ);
    2902           0 :         sStr.AppendAscii("\\o (\\s\\up ");
    2903           0 :         sStr += String::CreateFromInt32(nHeight/2);
    2904             : 
    2905           0 :         sStr.Append('(');
    2906           0 :         sStr += String(pFld->GetPar1(),0,nAbove);
    2907           0 :         sStr.AppendAscii("), \\s\\do ");
    2908           0 :         sStr += String::CreateFromInt32(nHeight/5);
    2909             : 
    2910           0 :         sStr.Append('(');
    2911           0 :         sStr += String(pFld->GetPar1(),nAbove,pFld->GetPar1().getLength()-nAbove);
    2912           0 :         sStr.AppendAscii("))");
    2913           0 :         GetExport().OutputField(pFld, ww::eEQ, sStr);
    2914             :         }
    2915           0 :         break;
    2916             :     case RES_DROPDOWN:
    2917           0 :         bWriteExpand = DropdownField( pFld );
    2918           0 :         break;
    2919             :     case RES_CHAPTERFLD:
    2920           0 :         bWriteExpand = true;
    2921           0 :         if (GetExport().bOutKF && rField.GetTxtFld())
    2922             :         {
    2923           0 :             const SwTxtNode *pTxtNd = GetExport().GetHdFtPageRoot();
    2924           0 :             if (!pTxtNd)
    2925             :             {
    2926           0 :                 if (const SwNode *pNd = GetExport().pCurPam->GetNode())
    2927           0 :                     pTxtNd = pNd->GetTxtNode();
    2928             :             }
    2929             : 
    2930           0 :             if (pTxtNd)
    2931             :             {
    2932           0 :                 SwChapterField aCopy(*(const SwChapterField*)pFld);
    2933           0 :                 aCopy.ChangeExpansion(*pTxtNd, false);
    2934           0 :                 WriteExpand( &aCopy );
    2935           0 :                 bWriteExpand = false;
    2936             :             }
    2937             :         }
    2938           0 :         break;
    2939             :         case RES_HIDDENTXTFLD:
    2940             :         {
    2941           0 :             String sExpand(pFld->GetPar2());
    2942           0 :             if (sExpand.Len())
    2943             :             {
    2944           0 :                 HiddenField( *pFld );
    2945           0 :             }
    2946             :         }
    2947           0 :         break;
    2948             :     default:
    2949           0 :         bWriteExpand = true;
    2950           0 :         break;
    2951             :     }
    2952             : 
    2953           4 :     if (bWriteExpand)
    2954           0 :         WriteExpand( pFld );
    2955           4 : }
    2956             : 
    2957         144 : void AttributeOutputBase::TextFlyContent( const SwFmtFlyCnt& rFlyContent )
    2958             : {
    2959         144 :     if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwCntntNode ) )
    2960             :     {
    2961         144 :         SwTxtNode* pTxtNd = (SwTxtNode*)GetExport().pOutFmtNode;
    2962             : 
    2963         144 :         Point aLayPos;
    2964         144 :         aLayPos = pTxtNd->FindLayoutRect( false, &aLayPos ).Pos();
    2965             : 
    2966         144 :         SwPosition aPos( *pTxtNd );
    2967         144 :         sw::Frame aFrm( *rFlyContent.GetFrmFmt(), aPos );
    2968             : 
    2969         144 :         OutputFlyFrame_Impl( aFrm, aLayPos );
    2970             :     }
    2971         144 : }
    2972             : 
    2973             : // TOXMarks fehlen noch
    2974             : 
    2975             : // Detaillierte Einstellungen zur Trennung erlaubt WW nur dokumentenweise.
    2976             : // Man koennte folgende Mimik einbauen: Die Werte des Style "Standard" werden,
    2977             : // falls vorhanden, in die Document Properties ( DOP ) gesetzt.
    2978             : // ---
    2979             : // ACK.  Dieser Vorschlag passt exakt zu unserer Implementierung des Import,
    2980             : // daher setze ich das gleich mal um. (KHZ, 07/15/2000)
    2981          12 : void WW8AttributeOutput::ParaHyphenZone( const SvxHyphenZoneItem& rHyphenZone )
    2982             : {
    2983             :     // sprmPFNoAutoHyph
    2984          12 :     if( m_rWW8Export.bWrtWW8 )
    2985          12 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoAutoHyph );
    2986             :     else
    2987           0 :         m_rWW8Export.pO->push_back( 44 );
    2988             : 
    2989          12 :     m_rWW8Export.pO->push_back( rHyphenZone.IsHyphen() ? 0 : 1 );
    2990          12 : }
    2991             : 
    2992          18 : void WW8AttributeOutput::ParaScriptSpace( const SfxBoolItem& rScriptSpace )
    2993             : {
    2994          18 :     sal_uInt16 nId = 0;
    2995          18 :     if ( m_rWW8Export.bWrtWW8 )
    2996          18 :         switch ( rScriptSpace.Which() )
    2997             :         {
    2998           6 :             case RES_PARATR_SCRIPTSPACE:            nId = NS_sprm::LN_PFAutoSpaceDE;   break;
    2999           6 :             case RES_PARATR_HANGINGPUNCTUATION:     nId = NS_sprm::LN_PFOverflowPunct;   break;
    3000           6 :             case RES_PARATR_FORBIDDEN_RULES:        nId = NS_sprm::LN_PFKinsoku;   break;
    3001             :         }
    3002             : 
    3003          18 :     if ( nId )
    3004             :     {
    3005          18 :         if( m_rWW8Export.bWrtWW8 )
    3006          18 :             m_rWW8Export.InsUInt16( nId );
    3007             :         else
    3008           0 :             m_rWW8Export.pO->push_back( (sal_uInt8)nId );
    3009             : 
    3010          18 :         m_rWW8Export.pO->push_back( rScriptSpace.GetValue() ? 1 : 0 );
    3011             :     }
    3012          18 : }
    3013             : 
    3014           0 : void WW8AttributeOutput::ParaSnapToGrid( const SvxParaGridItem& rGrid )
    3015             : {
    3016             :     // sprmPFUsePgsuSettings
    3017             :     // 97+ only
    3018           0 :     if ( !m_rWW8Export.bWrtWW8 )
    3019           0 :         return;
    3020             : 
    3021           0 :     m_rWW8Export.InsUInt16( NS_sprm::LN_PFUsePgsuSettings );
    3022           0 :     m_rWW8Export.pO->push_back( rGrid.GetValue() );
    3023             : }
    3024             : 
    3025           0 : void WW8AttributeOutput::ParaVerticalAlign( const SvxParaVertAlignItem& rAlign )
    3026             : {
    3027             :     // sprmPWAlignFont
    3028             :     // 97+ only
    3029           0 :     if( !m_rWW8Export.bWrtWW8 )
    3030           0 :         return;
    3031             : 
    3032           0 :     m_rWW8Export.InsUInt16( NS_sprm::LN_PWAlignFont );
    3033             : 
    3034           0 :     sal_Int16 nVal = rAlign.GetValue();
    3035           0 :     switch ( nVal )
    3036             :     {
    3037             :         case SvxParaVertAlignItem::BASELINE:
    3038           0 :             nVal = 2;
    3039           0 :             break;
    3040             :         case SvxParaVertAlignItem::TOP:
    3041           0 :             nVal = 0;
    3042           0 :             break;
    3043             :         case SvxParaVertAlignItem::CENTER:
    3044           0 :             nVal = 1;
    3045           0 :             break;
    3046             :         case SvxParaVertAlignItem::BOTTOM:
    3047           0 :             nVal = 3;
    3048           0 :             break;
    3049             :         case SvxParaVertAlignItem::AUTOMATIC:
    3050           0 :             nVal = 4;
    3051           0 :             break;
    3052             :         default:
    3053           0 :             nVal = 4;
    3054             :             OSL_FAIL( "Unknown vert alignment" );
    3055           0 :             break;
    3056             :     }
    3057           0 :     m_rWW8Export.InsUInt16( nVal );
    3058             : }
    3059             : 
    3060             : 
    3061             : // NoHyphen: ich habe keine Entsprechung in der SW-UI und WW-UI gefunden
    3062             : 
    3063             : 
    3064             : // RefMark, NoLineBreakHere  fehlen noch
    3065             : 
    3066           4 : void WW8Export::WriteFtnBegin( const SwFmtFtn& rFtn, ww::bytes* pOutArr )
    3067             : {
    3068           4 :     ww::bytes aAttrArr;
    3069           4 :     bool bAutoNum = !rFtn.GetNumStr().Len();    // Auto-Nummer
    3070           4 :     if( bAutoNum )
    3071             :     {
    3072           4 :         if( bWrtWW8 )
    3073             :         {
    3074             :             static const sal_uInt8 aSpec[] =
    3075             :             {
    3076             :                 0x03, 0x6a, 0, 0, 0, 0, // sprmCObjLocation
    3077             :                 0x55, 0x08, 1           // sprmCFSpec
    3078             :             };
    3079             : 
    3080           4 :             aAttrArr.insert(aAttrArr.end(), aSpec, aSpec+sizeof(aSpec));
    3081             :         }
    3082             :         else
    3083             :         {
    3084             :             static sal_uInt8 const aSpec[] =
    3085             :             {
    3086             :                 117, 1,                         // sprmCFSpec
    3087             :                 68, 4, 0, 0, 0, 0               // sprmCObjLocation
    3088             :             };
    3089             : 
    3090           0 :             aAttrArr.insert(aAttrArr.end(), aSpec, aSpec+sizeof(aSpec));
    3091             :         }
    3092             :     }
    3093             : 
    3094             :     // sprmCIstd
    3095             :     const SwEndNoteInfo* pInfo;
    3096           4 :     if( rFtn.IsEndNote() )
    3097           0 :         pInfo = &pDoc->GetEndNoteInfo();
    3098             :     else
    3099           4 :         pInfo = &pDoc->GetFtnInfo();
    3100             :     const SwCharFmt* pCFmt = pOutArr
    3101           2 :                                 ? pInfo->GetAnchorCharFmt( *pDoc )
    3102           6 :                                 : pInfo->GetCharFmt( *pDoc );
    3103           4 :     if( bWrtWW8 )
    3104           4 :         SwWW8Writer::InsUInt16( aAttrArr, NS_sprm::LN_CIstd );
    3105             :     else
    3106           0 :         aAttrArr.push_back( 80 );
    3107           4 :     SwWW8Writer::InsUInt16( aAttrArr, GetId( *pCFmt ) );
    3108             : 
    3109             :                                                 // fSpec-Attribut true
    3110             :                             // Fuer Auto-Nummer muss ein Spezial-Zeichen
    3111             :                             // in den Text und darum ein fSpec-Attribut
    3112           4 :     pChpPlc->AppendFkpEntry( Strm().Tell() );
    3113           4 :     if( bAutoNum )
    3114           4 :         WriteChar( 0x02 );              // Auto-Nummer-Zeichen
    3115             :     else
    3116             :         // User-Nummerierung
    3117           0 :         OutSwString( rFtn.GetNumStr(), 0, rFtn.GetNumStr().Len(),
    3118           0 :                         IsUnicode(), RTL_TEXTENCODING_MS_1252 );
    3119             : 
    3120           4 :     if( pOutArr )
    3121             :     {
    3122             :         // insert at start of array, so the "hard" attribute overrule the
    3123             :         // attributes of the character template
    3124           2 :         pOutArr->insert( pOutArr->begin(), aAttrArr.begin(), aAttrArr.end() );
    3125             :     }
    3126             :     else
    3127             :     {
    3128           2 :         ww::bytes aOutArr;
    3129             : 
    3130             :         // insert at start of array, so the "hard" attribute overrule the
    3131             :         // attributes of the character template
    3132           2 :         aOutArr.insert( aOutArr.begin(), aAttrArr.begin(), aAttrArr.end() );
    3133             : 
    3134             :         // write for the ftn number in the content, the font of the anchor
    3135           2 :         const SwTxtFtn* pTxtFtn = rFtn.GetTxtFtn();
    3136           2 :         if( pTxtFtn )
    3137             :         {
    3138           2 :             ww::bytes* pOld = pO;
    3139           2 :             pO = &aOutArr;
    3140           2 :             SfxItemSet aSet( pDoc->GetAttrPool(), RES_CHRATR_FONT,
    3141           2 :                                                   RES_CHRATR_FONT );
    3142             : 
    3143           2 :             pCFmt = pInfo->GetCharFmt( *pDoc );
    3144           2 :             aSet.Set( pCFmt->GetAttrSet() );
    3145             : 
    3146           4 :             pTxtFtn->GetTxtNode().GetAttr( aSet, *pTxtFtn->GetStart(),
    3147           6 :                                             (*pTxtFtn->GetStart()) + 1 );
    3148           2 :             m_pAttrOutput->OutputItem( aSet.Get( RES_CHRATR_FONT ) );
    3149           2 :             pO = pOld;
    3150             :         }
    3151           4 :         pChpPlc->AppendFkpEntry( Strm().Tell(), aOutArr.size(),
    3152           6 :                                                 aOutArr.data() );
    3153           4 :     }
    3154           4 : }
    3155             : 
    3156           4 : static bool lcl_IsAtTxtEnd(const SwFmtFtn& rFtn)
    3157             : {
    3158           4 :     bool bRet = true;
    3159           4 :     if( rFtn.GetTxtFtn() )
    3160             :     {
    3161           4 :         sal_uInt16 nWh = static_cast< sal_uInt16 >(rFtn.IsEndNote() ? RES_END_AT_TXTEND
    3162           4 :                                       : RES_FTN_AT_TXTEND);
    3163           4 :         const SwSectionNode* pSectNd = rFtn.GetTxtFtn()->GetTxtNode().
    3164           4 :                                                         FindSectionNode();
    3165           8 :         while( pSectNd && FTNEND_ATPGORDOCEND ==
    3166           0 :                 ((const SwFmtFtnAtTxtEnd&)pSectNd->GetSection().GetFmt()->
    3167           0 :                 GetFmtAttr( nWh, true)).GetValue() )
    3168           0 :             pSectNd = pSectNd->StartOfSectionNode()->FindSectionNode();
    3169             : 
    3170           4 :         if (!pSectNd)
    3171           4 :             bRet = false;   // the is ftn/end collected at Page- or Doc-End
    3172             :     }
    3173           4 :     return bRet;
    3174             : }
    3175             : 
    3176             : 
    3177           4 : void AttributeOutputBase::TextFootnote( const SwFmtFtn& rFtn )
    3178             : {
    3179             :     sal_uInt16 nTyp;
    3180           4 :     if ( rFtn.IsEndNote() )
    3181             :     {
    3182           0 :         nTyp = REF_ENDNOTE;
    3183           0 :         if ( GetExport().bEndAtTxtEnd )
    3184           0 :             GetExport().bEndAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
    3185             :     }
    3186             :     else
    3187             :     {
    3188           4 :         nTyp = REF_FOOTNOTE;
    3189           4 :         if ( GetExport().bFtnAtTxtEnd )
    3190           4 :             GetExport().bFtnAtTxtEnd = lcl_IsAtTxtEnd( rFtn );
    3191             :     }
    3192             : 
    3193             :     // if any reference to this footnote/endnote then insert an internal
    3194             :     // Bookmark.
    3195           4 :     String sBkmkNm;
    3196           4 :     if ( GetExport().HasRefToObject( nTyp, 0, rFtn.GetTxtFtn()->GetSeqRefNo() ))
    3197             :     {
    3198           0 :         sBkmkNm = GetExport().GetBookmarkName( nTyp, 0,
    3199           0 :                                     rFtn.GetTxtFtn()->GetSeqRefNo() );
    3200           0 :         GetExport().AppendBookmark( sBkmkNm );
    3201             :     }
    3202             : 
    3203           4 :     TextFootnote_Impl( rFtn );
    3204             : 
    3205           4 :     if ( sBkmkNm.Len() )
    3206           0 :         GetExport().AppendBookmark( sBkmkNm ); // FIXME: Why is it added twice?  Shouldn't this one go to WW8AttributeOuput::TextFootnote_Impl()?
    3207           4 : }
    3208             : 
    3209           2 : void WW8AttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFtn )
    3210             : {
    3211             :     WW8_WrPlcFtnEdn* pFtnEnd;
    3212           2 :     if ( rFtn.IsEndNote() )
    3213           0 :         pFtnEnd = m_rWW8Export.pEdn;
    3214             :     else
    3215           2 :         pFtnEnd = m_rWW8Export.pFtn;
    3216             : 
    3217           2 :     pFtnEnd->Append( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ), rFtn );
    3218           2 :     m_rWW8Export.WriteFtnBegin( rFtn, m_rWW8Export.pO );
    3219           2 : }
    3220             : 
    3221           0 : void WW8AttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
    3222             : {
    3223           0 :     if( rCharFmt.GetCharFmt() )
    3224             :     {
    3225           0 :         if( m_rWW8Export.bWrtWW8 )
    3226           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd );
    3227             :         else
    3228           0 :             m_rWW8Export.pO->push_back( 80 );
    3229             : 
    3230           0 :         m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *rCharFmt.GetCharFmt() ) );
    3231             :     }
    3232           0 : }
    3233             : 
    3234             : /*
    3235             :  See ww8par6.cxx Read_DoubleLine for some more info
    3236             :  */
    3237           0 : void WW8AttributeOutput::CharTwoLines( const SvxTwoLinesItem& rTwoLines )
    3238             : {
    3239             :     // #i28331# - check that bOn is set
    3240           0 :     if ( rTwoLines.GetValue() )
    3241             :     {
    3242             :         //97+ only
    3243           0 :         if( !m_rWW8Export.bWrtWW8 )
    3244           0 :             return;
    3245             : 
    3246           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_CEastAsianLayout );
    3247           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x06 ); //len 6
    3248           0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x02 );
    3249             : 
    3250           0 :         sal_Unicode cStart = rTwoLines.GetStartBracket();
    3251           0 :         sal_Unicode cEnd = rTwoLines.GetEndBracket();
    3252             : 
    3253             :         /*
    3254             :         As per usual we have problems. We can have seperate left and right brackets
    3255             :         in OOo, it doesn't appear that you can in word. Also in word there appear
    3256             :         to only be a limited number of possibilities, we can use pretty much
    3257             :         anything.
    3258             : 
    3259             :         So if we have none, we export none, if either bracket is set to a known
    3260             :         word type we export both as that type (with the bracket winning out in
    3261             :         the case of a conflict simply being the order of test here.
    3262             : 
    3263             :         Upshot being a documented created in word will be reexported with no
    3264             :         ill effects.
    3265             :         */
    3266             : 
    3267             :         sal_uInt16 nType;
    3268           0 :         if (!cStart && !cEnd)
    3269           0 :             nType = 0;
    3270           0 :         else if ((cStart == '{') || (cEnd == '}'))
    3271           0 :             nType = 4;
    3272           0 :         else if ((cStart == '<') || (cEnd == '>'))
    3273           0 :             nType = 3;
    3274           0 :         else if ((cStart == '[') || (cEnd == ']'))
    3275           0 :             nType = 2;
    3276             :         else
    3277           0 :             nType = 1;
    3278           0 :         m_rWW8Export.InsUInt16( nType );
    3279             :         static const sal_uInt8 aZeroArr[ 3 ] = { 0, 0, 0 };
    3280           0 :         m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aZeroArr, aZeroArr+3);
    3281             :     }
    3282             : }
    3283             : 
    3284           6 : void AttributeOutputBase::ParaNumRule( const SwNumRuleItem& rNumRule )
    3285             : {
    3286           6 :     const SwTxtNode* pTxtNd = 0;
    3287             :     sal_uInt16 nNumId;
    3288           6 :     sal_uInt8 nLvl = 0;
    3289           6 :     if ( rNumRule.GetValue().Len() )
    3290             :     {
    3291           6 :         const SwNumRule* pRule = GetExport().pDoc->FindNumRulePtr(
    3292          12 :                                         rNumRule.GetValue() );
    3293           6 :         if ( pRule && USHRT_MAX != ( nNumId = GetExport().GetId( *pRule ) ) )
    3294             :         {
    3295           6 :             ++nNumId;
    3296           6 :             if ( GetExport().pOutFmtNode )
    3297             :             {
    3298           6 :                 if ( GetExport().pOutFmtNode->ISA( SwCntntNode ) )
    3299             :                 {
    3300           0 :                     pTxtNd = (SwTxtNode*)GetExport().pOutFmtNode;
    3301             : 
    3302           0 :                     if( pTxtNd->IsCountedInList())
    3303             :                     {
    3304           0 :                         nLvl = static_cast< sal_uInt8 >(pTxtNd->GetActualListLevel());
    3305             : 
    3306           0 :                         if ( pTxtNd->IsListRestart() )
    3307             :                         {
    3308           0 :                             sal_uInt16 nStartWith = static_cast< sal_uInt16 >( pTxtNd->GetActualListStartValue() );
    3309           0 :                             nNumId = GetExport().DuplicateNumRule( pRule, nLvl, nStartWith );
    3310           0 :                             if ( USHRT_MAX != nNumId )
    3311           0 :                                 ++nNumId;
    3312             :                         }
    3313             :                     }
    3314             :                     else
    3315             :                     {
    3316             :                         // #i44815# adjust numbering for numbered paragraphs
    3317             :                         // without number (NO_NUMLEVEL). These paragaphs
    3318             :                         // will receive a list id 0, which WW interprets as
    3319             :                         // 'no number'.
    3320           0 :                         nNumId = 0;
    3321             :                     }
    3322             :                 }
    3323           6 :                 else if ( GetExport().pOutFmtNode->ISA( SwTxtFmtColl ) )
    3324             :                 {
    3325           6 :                     const SwTxtFmtColl* pC = (SwTxtFmtColl*)GetExport().pOutFmtNode;
    3326           6 :                     if ( pC && pC->IsAssignedToListLevelOfOutlineStyle() )
    3327           6 :                         nLvl = static_cast< sal_uInt8 >( pC->GetAssignedOutlineStyleLevel() ); //<-end,zhaojianwei
    3328             :                 }
    3329             :             }
    3330             :         }
    3331             :         else
    3332           0 :             nNumId = USHRT_MAX;
    3333             :     }
    3334             :     else
    3335           0 :         nNumId = 0;
    3336             : 
    3337           6 :     if ( USHRT_MAX != nNumId )
    3338             :     {
    3339           6 :         if ( nLvl >= WW8ListManager::nMaxLevel )
    3340           0 :             nLvl = WW8ListManager::nMaxLevel - 1;
    3341             : 
    3342           6 :         ParaNumRule_Impl( pTxtNd, nLvl, nNumId );
    3343             :     }
    3344           6 : }
    3345             : 
    3346           6 : void WW8AttributeOutput::ParaNumRule_Impl( const SwTxtNode* pTxtNd, sal_Int32 nLvl, sal_Int32 nNumId )
    3347             : {
    3348           6 :     if ( m_rWW8Export.bWrtWW8 )
    3349             :     {
    3350             :         // write sprmPIlvl and sprmPIlfo
    3351           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlvl );
    3352           6 :         m_rWW8Export.pO->push_back( ::sal::static_int_cast<sal_uInt8>(nLvl) );
    3353           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_PIlfo );
    3354           6 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, ::sal::static_int_cast<sal_uInt16>(nNumId) );
    3355             :     }
    3356           0 :     else if ( pTxtNd && m_rWW8Export.Out_SwNum( pTxtNd ) )                // NumRules
    3357           0 :         m_rWW8Export.pSepx->SetNum( pTxtNd );
    3358           6 : }
    3359             : 
    3360             : /* File FRMATR.HXX */
    3361             : 
    3362          10 : void WW8AttributeOutput::FormatFrameSize( const SwFmtFrmSize& rSize )
    3363             : {
    3364          10 :     if( m_rWW8Export.bOutFlyFrmAttrs )                   // Flys
    3365             :     {
    3366           0 :         if( m_rWW8Export.bOutGrf )
    3367          10 :             return;                // Fly um Grafik -> Auto-Groesse
    3368             : 
    3369             : //???? was ist bei Prozentangaben ???
    3370           0 :         if ( rSize.GetWidth() && rSize.GetWidthSizeType() == ATT_FIX_SIZE)
    3371             :         {
    3372             :             //"sprmPDxaWidth"
    3373           0 :             if( m_rWW8Export.bWrtWW8 )
    3374           0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaWidth );
    3375             :             else
    3376           0 :                 m_rWW8Export.pO->push_back( 28 );
    3377           0 :             m_rWW8Export.InsUInt16( (sal_uInt16)rSize.GetWidth() );
    3378             :         }
    3379             : 
    3380           0 :         if ( rSize.GetHeight() )
    3381             :         {
    3382             :             // sprmPWHeightAbs
    3383           0 :             if( m_rWW8Export.bWrtWW8 )
    3384           0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_PWHeightAbs );
    3385             :             else
    3386           0 :                 m_rWW8Export.pO->push_back( 45 );
    3387             : 
    3388           0 :             sal_uInt16 nH = 0;
    3389           0 :             switch ( rSize.GetHeightSizeType() )
    3390             :             {
    3391           0 :                 case ATT_VAR_SIZE: break;
    3392           0 :                 case ATT_FIX_SIZE: nH = (sal_uInt16)rSize.GetHeight() & 0x7fff; break;
    3393           0 :                 default:           nH = (sal_uInt16)rSize.GetHeight() | 0x8000; break;
    3394             :             }
    3395           0 :             m_rWW8Export.InsUInt16( nH );
    3396             :         }
    3397             :     }
    3398          10 :     else if( m_rWW8Export.bOutPageDescs )            // PageDesc : Breite + Hoehe
    3399             :     {
    3400          10 :         if( m_rWW8Export.pAktPageDesc->GetLandscape() )
    3401             :         {
    3402             :             /*sprmSBOrientation*/
    3403           0 :             if( m_rWW8Export.bWrtWW8 )
    3404           0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_SBOrientation );
    3405             :             else
    3406           0 :                 m_rWW8Export.pO->push_back( 162 );
    3407           0 :             m_rWW8Export.pO->push_back( 2 );
    3408             :         }
    3409             : 
    3410             :         /*sprmSXaPage*/
    3411          10 :         if( m_rWW8Export.bWrtWW8 )
    3412          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SXaPage );
    3413             :         else
    3414           0 :             m_rWW8Export.pO->push_back( 164 );
    3415             :         m_rWW8Export.InsUInt16(
    3416          10 :             msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetWidth())));
    3417             : 
    3418             :         /*sprmSYaPage*/
    3419          10 :         if( m_rWW8Export.bWrtWW8 )
    3420          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SYaPage );
    3421             :         else
    3422           0 :             m_rWW8Export.pO->push_back( 165 );
    3423             :         m_rWW8Export.InsUInt16(
    3424          10 :             msword_cast<sal_uInt16>(SvxPaperInfo::GetSloppyPaperDimension(rSize.GetHeight())));
    3425             :     }
    3426             : }
    3427             : 
    3428             : // FillOrder fehlt noch
    3429             : 
    3430             : // ReplaceCr() wird fuer Pagebreaks und Pagedescs gebraucht. Es wird ein
    3431             : // bereits geschriebenes CR durch ein Break-Zeichen ersetzt. Replace muss
    3432             : // direkt nach Schreiben des CR gerufen werden.
    3433             : // Rueckgabe: FilePos des ersetzten CRs + 1 oder 0 fuer nicht ersetzt
    3434             : 
    3435           6 : sal_uLong WW8Export::ReplaceCr( sal_uInt8 nChar )
    3436             : {
    3437             :     OSL_ENSURE( nChar, "gegen 0 ersetzt bringt WW97/95 zum Absturz" );
    3438             : 
    3439           6 :     bool bReplaced = false;
    3440           6 :     SvStream& rStrm = Strm();
    3441           6 :     sal_uLong nRetPos = 0, nPos = rStrm.Tell();
    3442             :     //If there is at least two characters already output
    3443           6 :     if (nPos - (IsUnicode() ? 2 : 1) >= sal_uLong(pFib->fcMin))
    3444             :     {
    3445           2 :         sal_uInt8 nBCode=0;
    3446           2 :         sal_uInt16 nUCode=0;
    3447             : 
    3448           2 :         rStrm.SeekRel(IsUnicode() ? -2 : -1);
    3449           2 :         if (IsUnicode())
    3450           2 :             rStrm >> nUCode;
    3451             :         else
    3452             :         {
    3453           0 :             rStrm >> nBCode;
    3454           0 :             nUCode = nBCode;
    3455             :         }
    3456             :         //If the last char was a cr
    3457           2 :         if (nUCode == 0x0d)             // CR ?
    3458             :         {
    3459           4 :             if ((nChar == 0x0c) &&
    3460           2 :                 (nPos - (IsUnicode() ? 4 : 2) >= sal_uLong(pFib->fcMin)))
    3461             :             {
    3462           2 :                 rStrm.SeekRel( IsUnicode() ? -4 : -2 );
    3463           2 :                 if (IsUnicode())
    3464           2 :                     rStrm >> nUCode;
    3465             :                 else
    3466             :                 {
    3467           0 :                     rStrm >> nUCode;
    3468           0 :                     nUCode = nBCode;
    3469             :                 }
    3470             :             }
    3471             :             else
    3472             :             {
    3473           0 :                 rStrm.SeekRel( IsUnicode() ? -2 : -1 );
    3474           0 :                 nUCode = 0x0;
    3475             :             }
    3476             :             //And the para is not of len 0, then replace this cr with the mark
    3477           2 :             if( nChar == 0x0e || nUCode == 0x0d )
    3478           0 :                 bReplaced = false;
    3479             :             else
    3480             :             {
    3481           2 :                 bReplaced = true;
    3482           2 :                 WriteChar(nChar);
    3483           2 :                 nRetPos = nPos;
    3484             :             }
    3485             :         }
    3486           0 :         else if ((nUCode == 0x0c) && (nChar == 0x0e))
    3487             :         {
    3488             :             // a column break after a section has no effect in writer
    3489           0 :             bReplaced = true;
    3490             :         }
    3491           2 :         rStrm.Seek( nPos );
    3492             :     }
    3493             :     else
    3494           4 :         bReplaced = true;
    3495             : 
    3496           6 :     if (!bReplaced)
    3497             :     {
    3498             :         // then write as normal char
    3499           0 :         WriteChar(nChar);
    3500           0 :         pPiece->SetParaBreak();
    3501           0 :         pPapPlc->AppendFkpEntry(rStrm.Tell());
    3502           0 :         pChpPlc->AppendFkpEntry(rStrm.Tell());
    3503           0 :         nRetPos = rStrm.Tell();
    3504             :     }
    3505           6 :     return nRetPos;
    3506             : }
    3507             : 
    3508           0 : void WW8AttributeOutput::TableRowEnd(sal_uInt32 nDepth)
    3509             : {
    3510           0 :     if ( nDepth == 1 )
    3511           0 :         m_rWW8Export.WriteChar( (sal_uInt8)0x07 );
    3512           0 :     else if ( nDepth > 1 )
    3513           0 :         m_rWW8Export.WriteChar( (sal_uInt8)0x0d );
    3514             : 
    3515             :     //Technically in a word document this is a different value for a row ends
    3516             :     //that are not row ends directly after a cell with a graphic. But it
    3517             :     //doesn't seem to make a difference
    3518             :     //pMagicTable->Append(Fc2Cp(Strm().Tell()),0x1B6);
    3519           0 : }
    3520             : 
    3521         100 : void AttributeOutputBase::FormatPageDescription( const SwFmtPageDesc& rPageDesc )
    3522             : {
    3523         100 :     if ( GetExport().bStyDef && GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtFmtColl ) )
    3524             :     {
    3525           2 :         const SwTxtFmtColl* pC = (SwTxtFmtColl*)GetExport().pOutFmtNode;
    3526           2 :         if ( (SFX_ITEM_SET != pC->GetItemState( RES_BREAK, false ) ) && rPageDesc.KnowsPageDesc() )
    3527           0 :             FormatBreak( SvxFmtBreakItem( SVX_BREAK_PAGE_BEFORE, RES_BREAK ) );
    3528             :     }
    3529         100 : }
    3530             : 
    3531           8 : void WW8AttributeOutput::PageBreakBefore( bool bBreak )
    3532             : {
    3533             :     // sprmPPageBreakBefore/sprmPFPageBreakBefore
    3534           8 :     if ( m_rWW8Export.bWrtWW8 )
    3535           8 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFPageBreakBefore );
    3536             :     else
    3537           0 :         m_rWW8Export.pO->push_back( 9 );
    3538             : 
    3539           8 :     m_rWW8Export.pO->push_back( bBreak ? 1 : 0 );
    3540           8 : }
    3541             : 
    3542             : // Breaks schreiben nichts in das Ausgabe-Feld rWrt.pO,
    3543             : // sondern nur in den Text-Stream ( Bedingung dafuer, dass sie von Out_Break...
    3544             : // gerufen werden duerfen )
    3545          16 : void AttributeOutputBase::FormatBreak( const SvxFmtBreakItem& rBreak )
    3546             : {
    3547          16 :     if ( GetExport().bStyDef )
    3548             :     {
    3549           0 :         switch ( rBreak.GetBreak() )
    3550             :         {
    3551             :             case SVX_BREAK_NONE:
    3552             :             case SVX_BREAK_PAGE_BEFORE:
    3553             :             case SVX_BREAK_PAGE_BOTH:
    3554           0 :                 PageBreakBefore( rBreak.GetValue() );
    3555           0 :                 break;
    3556             :             default:
    3557           0 :                 break;
    3558             :         }
    3559             :     }
    3560          16 :     else if ( !GetExport().mpParentFrame )
    3561             :     {
    3562          16 :         sal_uInt8 nC = 0;
    3563          16 :         bool bBefore = false;
    3564             :         // #i76300# - Note: Can only be <true>, if <bBefore> equals <false>.
    3565          16 :         bool bCheckForFollowPageDesc = false;
    3566             : 
    3567          16 :         switch ( rBreak.GetBreak() )
    3568             :         {
    3569             :             case SVX_BREAK_NONE:                                // Ausgeschaltet
    3570           0 :                 if ( !GetExport().bBreakBefore )
    3571           0 :                     PageBreakBefore( false );
    3572          16 :                 return;
    3573             : 
    3574             :             case SVX_BREAK_COLUMN_BEFORE:                       // ColumnBreak
    3575           0 :                 bBefore = true;
    3576             :                 // no break;
    3577             :             case SVX_BREAK_COLUMN_AFTER:
    3578             :             case SVX_BREAK_COLUMN_BOTH:
    3579           0 :                 if ( GetExport().Sections().CurrentNumberOfColumns( *GetExport().pDoc ) > 1 )
    3580             :                 {
    3581           0 :                     nC = msword::ColumnBreak;
    3582             :                 }
    3583           0 :                 break;
    3584             : 
    3585             :             case SVX_BREAK_PAGE_BEFORE:                         // PageBreak
    3586             :                 // From now on(fix for #i77900#) we prefer to save a page break as
    3587             :                 // paragraph attribute, this has to be done after the export of the
    3588             :                 // paragraph ( => !GetExport().bBreakBefore )
    3589          16 :                 if ( !GetExport().bBreakBefore )
    3590           8 :                     PageBreakBefore( true );
    3591          16 :                 break;
    3592             : 
    3593             :             case SVX_BREAK_PAGE_AFTER:
    3594             :             case SVX_BREAK_PAGE_BOTH:
    3595           0 :                 nC = msword::PageBreak;
    3596             :                 // #i76300# - check for follow page description,
    3597             :                 // if current writing attributes of a paragraph.
    3598           0 :                 if ( dynamic_cast< const SwTxtNode* >( GetExport().pOutFmtNode ) &&
    3599           0 :                      GetExport().GetCurItemSet() )
    3600             :                 {
    3601           0 :                     bCheckForFollowPageDesc = true;
    3602             :                 }
    3603           0 :                 break;
    3604             : 
    3605             :             default:
    3606           0 :                 break;
    3607             :         }
    3608             : 
    3609          16 :         if ( ( bBefore == GetExport().bBreakBefore ) && nC )
    3610             :         {
    3611             :             // #i76300#
    3612           0 :             bool bFollowPageDescWritten = false;
    3613           0 :             if ( bCheckForFollowPageDesc && !bBefore )
    3614             :             {
    3615             :                 bFollowPageDescWritten =
    3616           0 :                     GetExport().OutputFollowPageDesc( GetExport().GetCurItemSet(),
    3617           0 :                             dynamic_cast<const SwTxtNode*>( GetExport().pOutFmtNode ) );
    3618             :             }
    3619           0 :             if ( !bFollowPageDescWritten )
    3620             :             {
    3621           0 :                 SectionBreak( nC );
    3622             :             }
    3623             :         }
    3624             :     }
    3625             : }
    3626             : 
    3627           0 : void WW8AttributeOutput::SectionBreak( sal_uInt8 nC, const WW8_SepInfo* /*pSectionInfo*/ )
    3628             : {
    3629           0 :     m_rWW8Export.ReplaceCr( nC );
    3630           0 : }
    3631             : 
    3632          50 : sal_uInt32 AttributeOutputBase::GridCharacterPitch( const SwTextGridItem& rGrid ) const
    3633             : {
    3634          50 :     MSWordStyles * pStyles = GetExport().pStyles;
    3635          50 :     const SwFmt * pSwFmt = pStyles->GetSwFmt();
    3636             : 
    3637          50 :     sal_uInt32 nPageCharSize = 0;
    3638             : 
    3639          50 :     if (pSwFmt != NULL)
    3640             :     {
    3641             :         nPageCharSize = ItemGet<SvxFontHeightItem>
    3642          50 :             (*pSwFmt, RES_CHRATR_FONTSIZE).GetHeight();
    3643             :     }
    3644          50 :     sal_uInt16 nPitch = rGrid.IsSquaredMode() ? rGrid.GetBaseHeight() :
    3645          50 :         rGrid.GetBaseWidth( );
    3646             : 
    3647          50 :     sal_Int32 nCharWidth = nPitch - nPageCharSize;
    3648          50 :     sal_Int32 nFraction = nCharWidth % 20;
    3649          50 :     if ( nCharWidth < 0 )
    3650           2 :         nFraction = 20 + nFraction;
    3651          50 :     nFraction = ( nFraction * 0xFFF ) / 20;
    3652          50 :     nFraction = ( nFraction & 0x00000FFF );
    3653             : 
    3654          50 :     sal_Int32 nMain = nCharWidth / 20;
    3655          50 :     if ( nCharWidth < 0 )
    3656           2 :         nMain -= 1;
    3657          50 :     nMain = nMain * 0x1000;
    3658          50 :     nMain = ( nMain & 0xFFFFF000 );
    3659             : 
    3660          50 :     return sal_uInt32( nFraction + nMain );
    3661             : }
    3662             : 
    3663          18 : void WW8AttributeOutput::FormatTextGrid( const SwTextGridItem& rGrid )
    3664             : {
    3665          18 :     if ( m_rWW8Export.bOutPageDescs && m_rWW8Export.bWrtWW8 )
    3666             :     {
    3667          10 :         sal_uInt16 nGridType = 0;
    3668          10 :         switch ( rGrid.GetGridType() )
    3669             :         {
    3670             :             default:
    3671             :                 OSL_FAIL("Unknown grid type");
    3672             :             case GRID_NONE:
    3673          10 :                 nGridType = 0;
    3674          10 :                 break;
    3675             :             case GRID_LINES_ONLY:
    3676           0 :                 nGridType = 2;
    3677           0 :                 break;
    3678             :             case GRID_LINES_CHARS:
    3679           0 :                 if ( rGrid.IsSnapToChars() )
    3680           0 :                     nGridType = 3;
    3681             :                 else
    3682           0 :                     nGridType = 1;
    3683           0 :                 break;
    3684             :         }
    3685          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SClm );
    3686          10 :         m_rWW8Export.InsUInt16( nGridType );
    3687             : 
    3688          10 :         sal_uInt16 nHeight = rGrid.GetBaseHeight() + rGrid.GetRubyHeight();
    3689          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaLinePitch );
    3690          10 :         m_rWW8Export.InsUInt16( nHeight );
    3691             : 
    3692          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SDxtCharSpace );
    3693          10 :         m_rWW8Export.InsUInt32( GridCharacterPitch( rGrid ) );
    3694             :     }
    3695          18 : }
    3696             : 
    3697           0 : void WW8AttributeOutput::FormatPaperBin( const SvxPaperBinItem& rPaperBin )
    3698             : {
    3699           0 :     if ( m_rWW8Export.bOutPageDescs )
    3700             :     {
    3701             :         sal_uInt16 nVal;
    3702           0 :         switch ( rPaperBin.GetValue() )
    3703             :         {
    3704           0 :             case 0: nVal = 15;  break;      // Automatically select
    3705           0 :             case 1: nVal = 1;   break;      // Upper paper tray
    3706           0 :             case 2: nVal = 4;   break;      // Manual paper feed
    3707           0 :             default: nVal = 0;  break;
    3708             :         }
    3709             : 
    3710           0 :         if ( nVal )
    3711             :         {
    3712           0 :             if( m_rWW8Export.bWrtWW8 )
    3713           0 :                 m_rWW8Export.InsUInt16( m_rWW8Export.bOutFirstPage? NS_sprm::LN_SDmBinFirst: NS_sprm::LN_SDmBinOther );
    3714             :             else
    3715           0 :                 m_rWW8Export.pO->push_back( m_rWW8Export.bOutFirstPage? 140: 141 );
    3716             : 
    3717           0 :             m_rWW8Export.InsUInt16( nVal );
    3718             :         }
    3719             :     }
    3720           0 : }
    3721             : 
    3722          38 : void WW8AttributeOutput::FormatLRSpace( const SvxLRSpaceItem& rLR )
    3723             : {
    3724             :     // Flys fehlen noch ( siehe RTF )
    3725             : 
    3726          38 :     if ( m_rWW8Export.bOutFlyFrmAttrs )                   // Flys
    3727             :     {
    3728             :         // sprmPDxaFromText10
    3729           0 :         if( m_rWW8Export.bWrtWW8 )
    3730           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaFromText10 );
    3731             :         else
    3732           0 :             m_rWW8Export.pO->push_back( 49 );
    3733             :         // Mittelwert nehmen, da WW nur 1 Wert kennt
    3734           0 :         m_rWW8Export.InsUInt16( (sal_uInt16) ( ( rLR.GetLeft() + rLR.GetRight() ) / 2 ) );
    3735             :     }
    3736          38 :     else if ( m_rWW8Export.bOutPageDescs )                // PageDescs
    3737             :     {
    3738             :         sal_uInt16 nLDist, nRDist;
    3739          10 :         const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_BOX );
    3740          10 :         if ( pItem )
    3741             :         {
    3742           0 :             nRDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_LEFT );
    3743           0 :             nLDist = ((SvxBoxItem*)pItem)->CalcLineSpace( BOX_LINE_RIGHT );
    3744             :         }
    3745             :         else
    3746          10 :             nLDist = nRDist = 0;
    3747          10 :         nLDist = nLDist + (sal_uInt16)rLR.GetLeft();
    3748          10 :         nRDist = nRDist + (sal_uInt16)rLR.GetRight();
    3749             : 
    3750             :         // sprmSDxaLeft
    3751          10 :         if( m_rWW8Export.bWrtWW8 )
    3752          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaLeft );
    3753             :         else
    3754           0 :             m_rWW8Export.pO->push_back( 166 );
    3755          10 :         m_rWW8Export.InsUInt16( nLDist );
    3756             : 
    3757             :         // sprmSDxaRight
    3758          10 :         if( m_rWW8Export.bWrtWW8 )
    3759          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaRight );
    3760             :         else
    3761           0 :             m_rWW8Export.pO->push_back( 167 );
    3762          10 :         m_rWW8Export.InsUInt16( nRDist );
    3763             :     }
    3764             :     else
    3765             :     {                                          // normale Absaetze
    3766             :         // sprmPDxaLeft
    3767          28 :         if( m_rWW8Export.bWrtWW8 )
    3768             :         {
    3769          28 :             m_rWW8Export.InsUInt16( 0x845E );        //asian version ?
    3770          28 :             m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetTxtLeft() );
    3771             :         }
    3772             :         else
    3773             :         {
    3774           0 :             m_rWW8Export.pO->push_back( 17 );
    3775           0 :             m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetTxtLeft() );
    3776             :         }
    3777             : 
    3778             :         // sprmPDxaRight
    3779          28 :         if( m_rWW8Export.bWrtWW8 )
    3780             :         {
    3781          28 :             m_rWW8Export.InsUInt16( 0x845D );        //asian version ?
    3782          28 :             m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetRight() );
    3783             :         }
    3784             :         else
    3785             :         {
    3786           0 :             m_rWW8Export.pO->push_back( 16 );
    3787           0 :             m_rWW8Export.InsUInt16( (sal_uInt16)rLR.GetRight() );
    3788             :         }
    3789             : 
    3790             :         // sprmPDxaLeft1
    3791          28 :         if( m_rWW8Export.bWrtWW8 )
    3792             :         {
    3793          28 :             m_rWW8Export.InsUInt16( 0x8460 );        //asian version ?
    3794          28 :             m_rWW8Export.InsUInt16( rLR.GetTxtFirstLineOfst() );
    3795             :         }
    3796             :         else
    3797             :         {
    3798           0 :             m_rWW8Export.pO->push_back( 19 );
    3799           0 :             m_rWW8Export.InsUInt16( rLR.GetTxtFirstLineOfst() );
    3800             :         }
    3801             :     }
    3802          38 : }
    3803             : 
    3804          78 : void WW8AttributeOutput::FormatULSpace( const SvxULSpaceItem& rUL )
    3805             : {
    3806             :     // Flys fehlen noch ( siehe RTF )
    3807             : 
    3808          78 :     if ( m_rWW8Export.bOutFlyFrmAttrs )                   // Flys
    3809             :     {
    3810             :         // sprmPDyaFromText
    3811           0 :         if( m_rWW8Export.bWrtWW8 )
    3812           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaFromText );
    3813             :         else
    3814           0 :             m_rWW8Export.pO->push_back( 48 );
    3815             :         // Mittelwert nehmen, da WW nur 1 Wert kennt
    3816           0 :         m_rWW8Export.InsUInt16( (sal_uInt16) ( ( rUL.GetUpper() + rUL.GetLower() ) / 2 ) );
    3817             :     }
    3818          78 :     else if ( m_rWW8Export.bOutPageDescs )            // Page-UL
    3819             :     {
    3820             :         OSL_ENSURE( m_rWW8Export.GetCurItemSet(), "Impossible" );
    3821          10 :         if ( !m_rWW8Export.GetCurItemSet() )
    3822          78 :             return;
    3823             : 
    3824          10 :         HdFtDistanceGlue aDistances( *m_rWW8Export.GetCurItemSet() );
    3825             : 
    3826          10 :         if ( aDistances.HasHeader() )
    3827             :         {
    3828             :             //sprmSDyaHdrTop
    3829           6 :             if ( m_rWW8Export.bWrtWW8 )
    3830           6 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrTop );
    3831             :             else
    3832           0 :                 m_rWW8Export.pO->push_back( 156 );
    3833           6 :             m_rWW8Export.InsUInt16( aDistances.dyaHdrTop );
    3834             :         }
    3835             : 
    3836             :         // sprmSDyaTop
    3837          10 :         if ( m_rWW8Export.bWrtWW8 )
    3838          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaTop );
    3839             :         else
    3840           0 :             m_rWW8Export.pO->push_back( 168 );
    3841          10 :         m_rWW8Export.InsUInt16( aDistances.dyaTop );
    3842             : 
    3843          10 :         if ( aDistances.HasFooter() )
    3844             :         {
    3845             :             //sprmSDyaHdrBottom
    3846           6 :             if ( m_rWW8Export.bWrtWW8 )
    3847           6 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaHdrBottom );
    3848             :             else
    3849           0 :                 m_rWW8Export.pO->push_back( 157 );
    3850           6 :             m_rWW8Export.InsUInt16( aDistances.dyaHdrBottom );
    3851             :         }
    3852             : 
    3853             :         //sprmSDyaBottom
    3854          10 :         if ( m_rWW8Export.bWrtWW8 )
    3855          10 :             m_rWW8Export.InsUInt16( NS_sprm::LN_SDyaBottom );
    3856             :         else
    3857           0 :             m_rWW8Export.pO->push_back( 169 );
    3858          10 :         m_rWW8Export.InsUInt16( aDistances.dyaBottom );
    3859             :     }
    3860             :     else
    3861             :     {
    3862             :         // sprmPDyaBefore
    3863          68 :         if ( m_rWW8Export.bWrtWW8 )
    3864          68 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaBefore );
    3865             :         else
    3866           0 :             m_rWW8Export.pO->push_back( 21 );
    3867          68 :         m_rWW8Export.InsUInt16( rUL.GetUpper() );
    3868             :         // sprmPDyaAfter
    3869          68 :         if( m_rWW8Export.bWrtWW8 )
    3870          68 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAfter );
    3871             :         else
    3872           0 :             m_rWW8Export.pO->push_back( 22 );
    3873          68 :         m_rWW8Export.InsUInt16( rUL.GetLower() );
    3874             :         // sprmPFContextualSpacing
    3875          68 :         if (m_rWW8Export.bWrtWW8 && rUL.GetContext())
    3876             :         {
    3877           0 :             m_rWW8Export.InsUInt16(NS_sprm::LN_PContextualSpacing);
    3878           0 :             m_rWW8Export.pO->push_back( (sal_uInt8)rUL.GetContext() );
    3879             :         }
    3880             :     }
    3881             : }
    3882             : 
    3883             : // Print, Opaque, Protect fehlen noch
    3884             : 
    3885           0 : void WW8AttributeOutput::FormatSurround( const SwFmtSurround& rSurround )
    3886             : {
    3887           0 :     if ( m_rWW8Export.bOutFlyFrmAttrs )
    3888             :     {
    3889           0 :         if ( m_rWW8Export.bWrtWW8 )
    3890           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PWr );
    3891             :         else
    3892           0 :             m_rWW8Export.pO->push_back( 37 );
    3893             : 
    3894             :         m_rWW8Export.pO->push_back(
    3895           0 :                 ( SURROUND_NONE != rSurround.GetSurround() ) ? 2 : 1 );
    3896             :     }
    3897           0 : }
    3898             : 
    3899           0 : void WW8AttributeOutput::FormatVertOrientation( const SwFmtVertOrient& rFlyVert )
    3900             : {
    3901             : //!!!! Ankertyp und entsprechende Umrechnung fehlt noch
    3902             : 
    3903           0 :     if ( m_rWW8Export.bOutFlyFrmAttrs )
    3904             :     {
    3905             :         short nPos;
    3906           0 :         switch( rFlyVert.GetVertOrient() )
    3907             :         {
    3908             :             case text::VertOrientation::NONE:
    3909           0 :                 nPos = (short)rFlyVert.GetPos();
    3910           0 :                 break;
    3911             :             case text::VertOrientation::CENTER:
    3912             :             case text::VertOrientation::LINE_CENTER:
    3913           0 :                 nPos = -8;
    3914           0 :                 break;
    3915             :             case text::VertOrientation::BOTTOM:
    3916             :             case text::VertOrientation::LINE_BOTTOM:
    3917           0 :                 nPos = -12;
    3918           0 :                 break;
    3919             :             case text::VertOrientation::TOP:
    3920             :             case text::VertOrientation::LINE_TOP:
    3921             :             default:
    3922           0 :                 nPos = -4;
    3923           0 :                 break;
    3924             :         }
    3925             : 
    3926             :         // sprmPDyaAbs
    3927           0 :         if ( m_rWW8Export.bWrtWW8 )
    3928           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaAbs );
    3929             :         else
    3930           0 :             m_rWW8Export.pO->push_back( 27 );
    3931           0 :         m_rWW8Export.InsUInt16( nPos );
    3932             :     }
    3933           0 : }
    3934             : 
    3935             : 
    3936           0 : void WW8AttributeOutput::FormatHorizOrientation( const SwFmtHoriOrient& rFlyHori )
    3937             : {
    3938           0 :     if ( !m_rWW8Export.mpParentFrame )
    3939             :     {
    3940             :         OSL_ENSURE( m_rWW8Export.mpParentFrame, "HoriOrient without mpParentFrame !!" );
    3941           0 :         return;
    3942             :     }
    3943             : 
    3944             : //!!!! Ankertyp und entsprechende Umrechnung fehlt noch
    3945           0 :     if ( m_rWW8Export.bOutFlyFrmAttrs )
    3946             :     {
    3947             :         short nPos;
    3948           0 :         switch( rFlyHori.GetHoriOrient() )
    3949             :         {
    3950             :             case text::HoriOrientation::NONE:
    3951           0 :                 nPos = (short)rFlyHori.GetPos();
    3952           0 :                 if( !nPos )
    3953           0 :                     nPos = 1;   // WW: 0 ist reserviert
    3954           0 :                 break;
    3955             :             case text::HoriOrientation::LEFT:
    3956           0 :                 nPos = rFlyHori.IsPosToggle() ? -12 : 0;
    3957           0 :                 break;
    3958             :             case text::HoriOrientation::RIGHT:
    3959           0 :                 nPos = rFlyHori.IsPosToggle() ? -16 : -8;
    3960           0 :                 break;
    3961             :             case text::HoriOrientation::CENTER:
    3962             :             case text::HoriOrientation::FULL:                         // FULL nur fuer Tabellen
    3963             :             default:
    3964           0 :                 nPos = -4;
    3965           0 :                 break;
    3966             :         }
    3967             : 
    3968             :         // sprmPDxaAbs
    3969           0 :         if( m_rWW8Export.bWrtWW8 )
    3970           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PDxaAbs );
    3971             :         else
    3972           0 :             m_rWW8Export.pO->push_back( 26 );
    3973           0 :         m_rWW8Export.InsUInt16( nPos );
    3974             :     }
    3975             : }
    3976             : 
    3977           0 : void WW8AttributeOutput::FormatAnchor( const SwFmtAnchor& rAnchor )
    3978             : {
    3979             :     OSL_ENSURE( m_rWW8Export.mpParentFrame, "Anchor without mpParentFrame !!" );
    3980             : 
    3981           0 :     if ( m_rWW8Export.bOutFlyFrmAttrs )
    3982             :     {
    3983           0 :         sal_uInt8 nP = 0;
    3984           0 :         switch ( rAnchor.GetAnchorId() )
    3985             :         {
    3986             :             case FLY_AT_PAGE:
    3987             :                 // Vert: Page | Horz: Page
    3988           0 :                 nP |= (1 << 4) | (2 << 6);
    3989           0 :                 break;
    3990             :             // Im Fall eine Flys als Zeichen: Absatz-gebunden setzen!!!
    3991             :             case FLY_AT_FLY:
    3992             :             case FLY_AT_CHAR:
    3993             :             case FLY_AT_PARA:
    3994             :             case FLY_AS_CHAR:
    3995             :                 // Vert: Page | Horz: Page
    3996           0 :                 nP |= (2 << 4) | (0 << 6);
    3997           0 :                 break;
    3998             :             default:
    3999           0 :                 break;
    4000             :         }
    4001             : 
    4002             :         // sprmPPc
    4003           0 :         if ( m_rWW8Export.bWrtWW8 )
    4004           0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PPc );
    4005             :         else
    4006           0 :             m_rWW8Export.pO->push_back( 29 );
    4007           0 :         m_rWW8Export.pO->push_back( nP );
    4008             :     }
    4009           0 : }
    4010             : 
    4011           6 : void WW8AttributeOutput::FormatBackground( const SvxBrushItem& rBrush )
    4012             : {
    4013             :     // WW cannot have background in a section
    4014           6 :     if ( !m_rWW8Export.bOutPageDescs )
    4015             :     {
    4016           6 :         WW8_SHD aSHD;
    4017             : 
    4018           6 :         m_rWW8Export.TransBrush( rBrush.GetColor(), aSHD );
    4019             :         // sprmPShd
    4020           6 :         if ( m_rWW8Export.bWrtWW8 )
    4021           6 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PShd );
    4022             :         else
    4023           0 :             m_rWW8Export.pO->push_back(47);
    4024           6 :         m_rWW8Export.InsUInt16( aSHD.GetValue() );
    4025             : 
    4026             :         // Quite a few unknowns, some might be transparency or something
    4027             :         // of that nature...
    4028           6 :         if ( m_rWW8Export.bWrtWW8 )
    4029             :         {
    4030           6 :             m_rWW8Export.InsUInt16( 0xC64D );
    4031           6 :             m_rWW8Export.pO->push_back( 10 );
    4032           6 :             m_rWW8Export.InsUInt32( 0xFF000000 );
    4033           6 :             m_rWW8Export.InsUInt32( SuitableBGColor( rBrush.GetColor().GetColor() ) );
    4034           6 :             m_rWW8Export.InsUInt16( 0x0000 );
    4035             :         }
    4036             :     }
    4037           6 : }
    4038             : 
    4039           4 : WW8_BRC WW8Export::TranslateBorderLine(const SvxBorderLine& rLine,
    4040             :     sal_uInt16 nDist, bool bShadow)
    4041             : {
    4042             :     // M.M. This function writes out border lines to the word format similar to
    4043             :     // what SwRTFWriter::OutRTFBorder does in the RTF filter Eventually it
    4044             :     // would be nice if all this functionality was in the one place
    4045           4 :     WW8_BRC aBrc;
    4046             :     sal_uInt16 nWidth = ::editeng::ConvertBorderWidthToWord(
    4047           4 :             rLine.GetBorderLineStyle(), rLine.GetWidth());
    4048           4 :     sal_uInt8 brcType = 0, nColCode = 0;
    4049             : 
    4050           4 :     if( nWidth )                                // Linie ?
    4051             :     {
    4052             :         // BRC.brcType
    4053           4 :         bool bThick = !rLine.isDouble() && !bWrtWW8 && nWidth > 75;
    4054           4 :         if( bThick )
    4055           0 :             brcType = 2;
    4056             :         else
    4057             :         {
    4058           4 :             brcType = 0;
    4059           4 :             if ( bWrtWW8 )
    4060             :             {
    4061             :                 // All the border types values are available on
    4062             :                 // http://msdn.microsoft.com/en-us/library/dd908142%28v=office.12%29.aspx
    4063           4 :                 switch (rLine.GetBorderLineStyle())
    4064             :                 {
    4065             :                     case table::BorderLineStyle::SOLID:
    4066             :                         {
    4067           4 :                             if ( rLine.GetWidth( ) == DEF_LINE_WIDTH_0 )
    4068           0 :                                 brcType = 5;
    4069             :                             else
    4070           4 :                                 brcType = 1;
    4071             :                         }
    4072           4 :                         break;
    4073             :                     case table::BorderLineStyle::DOTTED:
    4074           0 :                         brcType = 6;
    4075           0 :                         break;
    4076             :                     case table::BorderLineStyle::DASHED:
    4077           0 :                         brcType = 7;
    4078           0 :                         break;
    4079             :                     case table::BorderLineStyle::DOUBLE:
    4080           0 :                         brcType = 3;
    4081           0 :                         break;
    4082             :                     case table::BorderLineStyle::THINTHICK_SMALLGAP:
    4083           0 :                         brcType = 11;
    4084           0 :                         break;
    4085             :                     case table::BorderLineStyle::THINTHICK_MEDIUMGAP:
    4086           0 :                         brcType = 14;
    4087           0 :                         break;
    4088             :                     case table::BorderLineStyle::THINTHICK_LARGEGAP:
    4089           0 :                         brcType = 17;
    4090           0 :                         break;
    4091             :                     case table::BorderLineStyle::THICKTHIN_SMALLGAP:
    4092           0 :                         brcType = 12;
    4093           0 :                         break;
    4094             :                     case table::BorderLineStyle::THICKTHIN_MEDIUMGAP:
    4095           0 :                         brcType = 15;
    4096           0 :                         break;
    4097             :                     case table::BorderLineStyle::THICKTHIN_LARGEGAP:
    4098           0 :                         brcType = 18;
    4099           0 :                         break;
    4100             :                     case table::BorderLineStyle::EMBOSSED:
    4101           0 :                         brcType = 24;
    4102           0 :                         break;
    4103             :                     case table::BorderLineStyle::ENGRAVED:
    4104           0 :                         brcType = 25;
    4105           0 :                         break;
    4106             :                     case table::BorderLineStyle::OUTSET:
    4107           0 :                         brcType = 26;
    4108           0 :                         break;
    4109             :                     case table::BorderLineStyle::INSET:
    4110           0 :                         brcType = 27;
    4111           0 :                         break;
    4112             :                     default:
    4113           0 :                         break;
    4114             :                 }
    4115             :             }
    4116             :         }
    4117             : 
    4118             :         // BRC.dxpLineWidth
    4119           4 :         if( bThick )
    4120           0 :             nWidth /= 2;
    4121             : 
    4122           4 :         if( bWrtWW8 )
    4123             :         {
    4124             :             // Angabe in 8tel Punkten, also durch 2.5, da 1 Punkt = 20 Twips
    4125           4 :             nWidth = (( nWidth * 8 ) + 10 ) / 20;
    4126           4 :             if( 0xff < nWidth )
    4127           0 :                 nWidth = 0xff;
    4128             :         }
    4129             :         else
    4130             :         {
    4131             :             // Angabe in 0.75 pt
    4132           0 :             nWidth = ( nWidth + 7 ) / 15;
    4133           0 :             if( nWidth > 5 )
    4134           0 :                 nWidth = 5;
    4135           0 :             ::editeng::SvxBorderStyle const eStyle(rLine.GetBorderLineStyle());
    4136           0 :             if (table::BorderLineStyle::DOTTED == eStyle)
    4137           0 :                 nWidth = 6;
    4138           0 :             else if (table::BorderLineStyle::DASHED == eStyle)
    4139           0 :                 nWidth = 7;
    4140             :         }
    4141             : 
    4142           4 :         if( 0 == nWidth )                       // ganz duenne Linie
    4143           0 :             nWidth = 1;                         //       nicht weglassen
    4144             : 
    4145             :         // BRC.ico
    4146           4 :         nColCode = TransCol( rLine.GetColor() );
    4147             :     }
    4148             : 
    4149             :     // BRC.dxpSpace
    4150           4 :     sal_uInt16 nLDist = nDist;
    4151           4 :     nLDist /= 20;               // Masseinheit : pt
    4152           4 :     if( nLDist > 0x1f )
    4153           0 :         nLDist = 0x1f;
    4154             : 
    4155           4 :     if( bWrtWW8 )
    4156             :     {
    4157           4 :         aBrc.aBits1[0] = sal_uInt8(nWidth);
    4158           4 :         aBrc.aBits1[1] = brcType;
    4159           4 :         aBrc.aBits2[0] = nColCode;
    4160           4 :         aBrc.aBits2[1] = sal_uInt8(nLDist);
    4161             : 
    4162             :         // fShadow, keine weiteren Einstellungen im WW moeglich
    4163           4 :         if( bShadow )
    4164           0 :             aBrc.aBits2[1] |= 0x20;
    4165             :     }
    4166             :     else
    4167             :     {
    4168           0 :         sal_uInt16 aBits = nWidth + ( brcType << 3 );
    4169           0 :         aBits |= (nColCode & 0x1f) << 6;
    4170           0 :         aBits |= nLDist << 11;
    4171             :         // fShadow, keine weiteren Einstellungen im WW moeglich
    4172           0 :         if( bShadow )
    4173           0 :             aBits |= 0x20;
    4174           0 :         ShortToSVBT16( aBits, aBrc.aBits1);
    4175             :     }
    4176             : 
    4177           4 :     return aBrc;
    4178             : }
    4179             : 
    4180             : // MakeBorderLine() bekommt einen WW8Bytes* uebergeben, um die Funktion
    4181             : // auch fuer die Tabellen-Umrandungen zu benutzen.
    4182             : // Wenn nSprmNo == 0, dann wird der Opcode nicht ausgegeben.
    4183             : // bShadow darf bei Tabellenzellen *nicht* gesetzt sein !
    4184          16 : void WW8Export::Out_BorderLine(ww::bytes& rO, const SvxBorderLine* pLine,
    4185             :     sal_uInt16 nDist, sal_uInt16 nSprmNo, bool bShadow)
    4186             : {
    4187             :     OSL_ENSURE( ( nSprmNo == 0 ) ||
    4188             :             ( nSprmNo >= 38 && nSprmNo <= 41 ) ||
    4189             :             ( nSprmNo >= NS_sprm::LN_PBrcTop && nSprmNo <= NS_sprm::LN_PBrcRight ) ||
    4190             :             ( nSprmNo >= NS_sprm::LN_SBrcTop && nSprmNo <= NS_sprm::LN_SBrcRight ),
    4191             :             "Sprm for border out is of range" );
    4192             : 
    4193          16 :     WW8_BRC aBrc;
    4194             : 
    4195          16 :     if (pLine)
    4196           4 :         aBrc = TranslateBorderLine( *pLine, nDist, bShadow );
    4197             : 
    4198          16 :     if( bWrtWW8 )
    4199             :     {
    4200             :         // WW97-SprmIds
    4201          16 :         if ( nSprmNo != 0 )
    4202          16 :             SwWW8Writer::InsUInt16( rO, nSprmNo );
    4203             : 
    4204          16 :         rO.insert( rO.end(), aBrc.aBits1, aBrc.aBits1+2 );
    4205          16 :         rO.insert( rO.end(), aBrc.aBits2, aBrc.aBits2+2 );
    4206             :     }
    4207             :     else
    4208             :     {
    4209             :         // WW95-SprmIds
    4210           0 :         if ( nSprmNo != 0 )
    4211           0 :             rO.push_back( static_cast<sal_uInt8>( nSprmNo ) );
    4212           0 :         rO.insert( rO.end(), aBrc.aBits1, aBrc.aBits1+2 );
    4213             :     }
    4214          16 : }
    4215             : 
    4216             : // FormatBox1() ist fuer alle Boxen ausser in Tabellen.
    4217             : // es wird pO des WW8Writers genommen
    4218           4 : void WW8Export::Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow)
    4219             : {
    4220           4 :     if ( bOutPageDescs && !bWrtWW8 )
    4221           4 :         return; // no page ouline in WW6
    4222             : 
    4223             :     static const sal_uInt16 aBorders[] =
    4224             :     {
    4225             :         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
    4226             :     };
    4227             :     static const sal_uInt16 aPBrc[] =
    4228             :     {
    4229             :         NS_sprm::LN_PBrcTop, NS_sprm::LN_PBrcLeft, NS_sprm::LN_PBrcBottom, NS_sprm::LN_PBrcRight
    4230             :     };
    4231             :     static const sal_uInt16 aSBrc[] =
    4232             :     {
    4233             :         NS_sprm::LN_SBrcTop, NS_sprm::LN_SBrcLeft, NS_sprm::LN_SBrcBottom, NS_sprm::LN_SBrcRight
    4234             :     };
    4235             :     static const sal_uInt16 aWW6PBrc[] =
    4236             :     {
    4237             :         38, 39, 40, 41
    4238             :     };
    4239             : 
    4240           4 :     const sal_uInt16* pBrd = aBorders;
    4241          20 :     for( sal_uInt16 i = 0; i < 4; ++i, ++pBrd )
    4242             :     {
    4243          16 :         const SvxBorderLine* pLn = rBox.GetLine( *pBrd );
    4244             : 
    4245          16 :         sal_uInt16 nSprmNo = 0;
    4246          16 :         if ( !bWrtWW8 )
    4247           0 :             nSprmNo = aWW6PBrc[i];
    4248          16 :         else if ( bOutPageDescs )
    4249           0 :             nSprmNo = aSBrc[i];
    4250             :         else
    4251          16 :             nSprmNo = aPBrc[i];
    4252             : 
    4253          16 :         Out_BorderLine( *pO, pLn, rBox.GetDistance( *pBrd ), nSprmNo, bShadow );
    4254             :     }
    4255             : }
    4256             : 
    4257             : // FormatBox2() ist fuer TC-Strukturen in Tabellen. Der Sprm-Opcode
    4258             : // wird nicht geschrieben, da es in der TC-Structur ohne Opcode gepackt ist.
    4259             : // dxpSpace wird immer 0, da WW das in Tabellen so verlangt
    4260             : // ( Tabellenumrandungen fransen sonst aus )
    4261             : // Ein WW8Bytes-Ptr wird als Ausgabe-Parameter uebergeben
    4262             : 
    4263           0 : void WW8Export::Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * pBox )
    4264             : {
    4265             :     // moeglich und vielleicht besser waere 0xffff
    4266             :     static const sal_uInt16 aBorders[] =
    4267             :     {
    4268             :         BOX_LINE_TOP, BOX_LINE_LEFT, BOX_LINE_BOTTOM, BOX_LINE_RIGHT
    4269             :     };
    4270           0 :     static const SvxBorderLine aBorderLine;
    4271             : 
    4272           0 :     const sal_uInt16* pBrd = aBorders;
    4273           0 :     for( int i = 0; i < 4; ++i, ++pBrd )
    4274             :     {
    4275             :         const SvxBorderLine* pLn;
    4276           0 :         if (pBox != NULL)
    4277           0 :             pLn = pBox->GetLine( *pBrd );
    4278             :         else
    4279           0 :             pLn = & aBorderLine;
    4280             : 
    4281           0 :         Out_BorderLine(rO, pLn, 0, 0, false);
    4282             :     }
    4283           0 : }
    4284             : 
    4285           4 : void WW8AttributeOutput::FormatBox( const SvxBoxItem& rBox )
    4286             : {
    4287             :     // Fly um Grafik-> keine Umrandung hier, da
    4288             :     // der GrafikHeader bereits die Umrandung hat
    4289           4 :     if ( !m_rWW8Export.bOutGrf )
    4290             :     {
    4291           4 :         bool bShadow = false;
    4292           4 :         const SfxPoolItem* pItem = m_rWW8Export.HasItem( RES_SHADOW );
    4293           4 :         if ( pItem )
    4294             :         {
    4295           0 :             const SvxShadowItem* p = (const SvxShadowItem*)pItem;
    4296           0 :             bShadow = ( p->GetLocation() != SVX_SHADOW_NONE )
    4297           0 :                       && ( p->GetWidth() != 0 );
    4298             :         }
    4299             : 
    4300           4 :         m_rWW8Export.Out_SwFmtBox( rBox, bShadow );
    4301             :     }
    4302           4 : }
    4303             : 
    4304           0 : SwTwips WW8Export::CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const
    4305             : {
    4306           0 :     const SwFrmFmt* pFmt = pAktPageDesc ? &pAktPageDesc->GetMaster()
    4307           0 :         : &pDoc->GetPageDesc(0).GetMaster();
    4308             : 
    4309           0 :     const SvxLRSpaceItem& rLR = pFmt->GetLRSpace();
    4310           0 :     SwTwips nPageSize = pFmt->GetFrmSize().GetWidth();
    4311           0 :     rLeft = rLR.GetLeft();
    4312           0 :     rRight = rLR.GetRight();
    4313           0 :     return nPageSize;
    4314             : }
    4315             : 
    4316           0 : void WW8AttributeOutput::FormatColumns_Impl( sal_uInt16 nCols, const SwFmtCol & rCol, bool bEven, SwTwips nPageSize )
    4317             : {
    4318             :     // CColumns
    4319           0 :     if ( m_rWW8Export.bWrtWW8 )
    4320           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SCcolumns );
    4321             :     else
    4322           0 :         m_rWW8Export.pO->push_back( 144 );
    4323           0 :     m_rWW8Export.InsUInt16( nCols - 1 );
    4324             : 
    4325             :     // DxaColumns
    4326           0 :     if ( m_rWW8Export.bWrtWW8 )
    4327           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColumns );
    4328             :     else
    4329           0 :         m_rWW8Export.pO->push_back( 145 );
    4330           0 :     m_rWW8Export.InsUInt16( rCol.GetGutterWidth( true ) );
    4331             : 
    4332             :     // LBetween
    4333           0 :     if ( m_rWW8Export.bWrtWW8 )
    4334           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SLBetween );
    4335             :     else
    4336           0 :         m_rWW8Export.pO->push_back( 158 );
    4337           0 :     m_rWW8Export.pO->push_back( COLADJ_NONE == rCol.GetLineAdj(  )? 0 : 1 );
    4338             : 
    4339           0 :     const SwColumns & rColumns = rCol.GetColumns(  );
    4340             : 
    4341             :     // FEvenlySpaced
    4342           0 :     if ( m_rWW8Export.bWrtWW8 )
    4343           0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SFEvenlySpaced );
    4344             :     else
    4345           0 :         m_rWW8Export.pO->push_back( 138 );
    4346           0 :     m_rWW8Export.pO->push_back( bEven ? 1 : 0 );
    4347             : 
    4348           0 :     if ( !bEven )
    4349             :     {
    4350           0 :         for ( sal_uInt16 n = 0; n < nCols; ++n )
    4351             :         {
    4352             :             //sprmSDxaColWidth
    4353           0 :             if ( m_rWW8Export.bWrtWW8 )
    4354           0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColWidth );
    4355             :             else
    4356           0 :                 m_rWW8Export.pO->push_back( 136 );
    4357           0 :             m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
    4358             :             m_rWW8Export.InsUInt16( rCol.
    4359             :                                     CalcPrtColWidth( n,
    4360           0 :                                                      ( sal_uInt16 ) nPageSize ) );
    4361             : 
    4362           0 :             if ( n + 1 != nCols )
    4363             :             {
    4364             :                 //sprmSDxaColSpacing
    4365           0 :                 if ( m_rWW8Export.bWrtWW8 )
    4366           0 :                     m_rWW8Export.InsUInt16( NS_sprm::LN_SDxaColSpacing );
    4367             :                 else
    4368           0 :                     m_rWW8Export.pO->push_back( 137 );
    4369           0 :                 m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(n) );
    4370           0 :                 m_rWW8Export.InsUInt16( rColumns[n].GetRight(  ) +
    4371           0 :                                         rColumns[n + 1].GetLeft(  ) );
    4372             :             }
    4373             :         }
    4374             :     }
    4375           0 : }
    4376             : 
    4377           0 : void AttributeOutputBase::FormatColumns( const SwFmtCol& rCol )
    4378             : {
    4379           0 :     const SwColumns& rColumns = rCol.GetColumns();
    4380             : 
    4381           0 :     sal_uInt16 nCols = rColumns.size();
    4382           0 :     if ( 1 < nCols && !GetExport( ).bOutFlyFrmAttrs )
    4383             :     {
    4384             :         // dann besorge mal die Seitenbreite ohne Raender !!
    4385             : 
    4386           0 :         const SwFrmFmt* pFmt = GetExport( ).pAktPageDesc ? &GetExport( ).pAktPageDesc->GetMaster() : &const_cast<const SwDoc *>(GetExport( ).pDoc)->GetPageDesc(0).GetMaster();
    4387           0 :         const SvxFrameDirectionItem &frameDirection = pFmt->GetFrmDir();
    4388             :         SwTwips nPageSize;
    4389           0 :         if ( frameDirection.GetValue() == FRMDIR_VERT_TOP_RIGHT || frameDirection.GetValue() == FRMDIR_VERT_TOP_LEFT )
    4390             :         {
    4391           0 :             const SvxULSpaceItem &rUL = pFmt->GetULSpace();
    4392           0 :             nPageSize = pFmt->GetFrmSize().GetHeight();
    4393           0 :             nPageSize -= rUL.GetUpper() + rUL.GetLower();
    4394             : 
    4395           0 :             const SwFmtHeader *header = dynamic_cast<const SwFmtHeader *>(pFmt->GetAttrSet().GetItem(RES_HEADER));
    4396           0 :             if ( header )
    4397             :             {
    4398           0 :                 const SwFrmFmt *headerFmt = header->GetHeaderFmt();
    4399           0 :                 if (headerFmt)
    4400             :                 {
    4401           0 :                     nPageSize -= headerFmt->GetFrmSize().GetHeight();
    4402             :                 }
    4403             :             }
    4404           0 :             const SwFmtFooter *footer = dynamic_cast<const SwFmtFooter *>(pFmt->GetAttrSet().GetItem(RES_FOOTER));
    4405           0 :             if ( footer )
    4406             :             {
    4407           0 :                 const SwFrmFmt *footerFmt = footer->GetFooterFmt();
    4408           0 :                 if ( footerFmt )
    4409             :                 {
    4410           0 :                     nPageSize -= footerFmt->GetFrmSize().GetHeight();
    4411             :                 }
    4412             :             }
    4413             :         }
    4414             :         else
    4415             :         {
    4416           0 :             const SvxLRSpaceItem &rLR = pFmt->GetLRSpace();
    4417           0 :             nPageSize = pFmt->GetFrmSize().GetWidth();
    4418           0 :             nPageSize -= rLR.GetLeft() + rLR.GetRight();
    4419             :         }
    4420             : 
    4421             :         // Nachsehen, ob alle Spalten gleich sind
    4422           0 :         bool bEven = true;
    4423             :         sal_uInt16 n;
    4424           0 :         sal_uInt16 nColWidth = rCol.CalcPrtColWidth( 0, (sal_uInt16)nPageSize );
    4425           0 :         for ( n = 1; n < nCols; n++ )
    4426             :         {
    4427             :             short nDiff = nColWidth -
    4428           0 :                 rCol.CalcPrtColWidth( n, (sal_uInt16)nPageSize );
    4429             : 
    4430           0 :             if ( nDiff > 10 || nDiff < -10 )      // Toleranz: 10 tw
    4431             :             {
    4432           0 :                 bEven = false;
    4433           0 :                 break;
    4434             :             }
    4435             :         }
    4436             : 
    4437           0 :         FormatColumns_Impl( nCols, rCol, bEven, nPageSize );
    4438             :     }
    4439           0 : }
    4440             : 
    4441             : // "Paragraphs together"
    4442          12 : void WW8AttributeOutput::FormatKeep( const SvxFmtKeepItem& rKeep )
    4443             : {
    4444             :     // sprmFKeepFollow
    4445          12 :     if ( m_rWW8Export.bWrtWW8 )
    4446          12 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeepFollow );
    4447             :     else
    4448           0 :         m_rWW8Export.pO->push_back( 8 );
    4449             : 
    4450          12 :     m_rWW8Export.pO->push_back( rKeep.GetValue() ? 1 : 0 );
    4451          12 : }
    4452             : 
    4453             : // exclude a paragraph from Line Numbering
    4454          28 : void WW8AttributeOutput::FormatLineNumbering( const SwFmtLineNumber& rNumbering )
    4455             : {
    4456             :     // sprmPFNoLineNumb
    4457          28 :     if( m_rWW8Export.bWrtWW8 )
    4458          28 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFNoLineNumb );
    4459             :     else
    4460           0 :         m_rWW8Export.pO->push_back( 14 );
    4461             : 
    4462          28 :     m_rWW8Export.pO->push_back( rNumbering.IsCount() ? 0 : 1 );
    4463          28 : }
    4464             : 
    4465             : 
    4466             : /* File PARATR.HXX  */
    4467             : 
    4468          18 : void WW8AttributeOutput::ParaLineSpacing_Impl( short nSpace, short nMulti )
    4469             : {
    4470             :     // sprmPDyaLine
    4471          18 :     if ( m_rWW8Export.bWrtWW8 )
    4472          18 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PDyaLine );
    4473             :     else
    4474           0 :         m_rWW8Export.pO->push_back( 20 );
    4475             : 
    4476          18 :     m_rWW8Export.InsUInt16( nSpace );
    4477          18 :     m_rWW8Export.InsUInt16( nMulti );
    4478          18 : }
    4479             : 
    4480          40 : void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing )
    4481             : {
    4482          40 :     short nSpace = 240, nMulti = 0;
    4483             : 
    4484          40 :     switch ( rSpacing.GetLineSpaceRule() )
    4485             :     {
    4486             :         default:
    4487           0 :             break;
    4488             :         case SVX_LINE_SPACE_AUTO:
    4489             :         case SVX_LINE_SPACE_FIX:
    4490             :         case SVX_LINE_SPACE_MIN:
    4491             :         {
    4492          40 :             switch ( rSpacing.GetInterLineSpaceRule() )
    4493             :             {
    4494             :                 case SVX_INTER_LINE_SPACE_FIX:      // unser Durchschuss
    4495             :                 {
    4496             :                     // gibt es aber nicht in WW - also wie kommt man an
    4497             :                     // die MaxLineHeight heran?
    4498           0 :                     nSpace = (short)rSpacing.GetInterLineSpace();
    4499             :                     sal_uInt16 nScript =
    4500           0 :                         i18n::ScriptType::LATIN;
    4501           0 :                     const SwAttrSet *pSet = 0;
    4502           0 :                     if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwFmt ) )
    4503             :                     {
    4504           0 :                         const SwFmt *pFmt = (const SwFmt*)( GetExport().pOutFmtNode );
    4505           0 :                         pSet = &pFmt->GetAttrSet();
    4506             :                     }
    4507           0 :                     else if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtNode ) )
    4508             :                     {
    4509           0 :                         const SwTxtNode* pNd = (const SwTxtNode*)GetExport().pOutFmtNode;
    4510           0 :                         pSet = &pNd->GetSwAttrSet();
    4511           0 :                         if ( pBreakIt->GetBreakIter().is() )
    4512             :                         {
    4513           0 :                             nScript = pBreakIt->GetBreakIter()->
    4514           0 :                                 getScriptType(pNd->GetTxt(), 0);
    4515             :                         }
    4516             :                     }
    4517             :                     OSL_ENSURE( pSet, "No attrset for lineheight :-(" );
    4518           0 :                     if ( pSet )
    4519             :                     {
    4520           0 :                         nSpace = nSpace + (short)( AttrSetToLineHeight( *GetExport().pDoc,
    4521           0 :                             *pSet, *Application::GetDefaultDevice(), nScript ) );
    4522             :                     }
    4523             :                 }
    4524           0 :                 break;
    4525             :             case SVX_INTER_LINE_SPACE_PROP:
    4526          28 :                 nSpace = (short)( ( 240L * rSpacing.GetPropLineSpace() ) / 100L );
    4527          28 :                 nMulti = 1;
    4528          28 :                 break;
    4529             :             default:                    // z.B. Minimum oder FIX?
    4530          12 :                 if ( SVX_LINE_SPACE_FIX == rSpacing.GetLineSpaceRule() )
    4531           0 :                     nSpace = -(short)rSpacing.GetLineHeight();
    4532             :                 else
    4533          12 :                     nSpace = (short)rSpacing.GetLineHeight();
    4534          12 :                 break;
    4535             :             }
    4536             :         }
    4537          40 :         break;
    4538             :     }
    4539             :     // if nSpace is negative, it is a fixed size in 1/20 of a point
    4540             :     // if nSpace is positive and nMulti is 1, it is 1/240 of a single line height
    4541             :     // otherwise, I have no clue what the heck it is
    4542          40 :     ParaLineSpacing_Impl( nSpace, nMulti );
    4543          40 : }
    4544             : 
    4545          12 : void WW8AttributeOutput::ParaAdjust( const SvxAdjustItem& rAdjust )
    4546             : {
    4547             :     // sprmPJc
    4548          12 :     sal_uInt8 nAdj = 255;
    4549          12 :     sal_uInt8 nAdjBiDi = 255;
    4550          12 :     switch ( rAdjust.GetAdjust() )
    4551             :     {
    4552             :         case SVX_ADJUST_LEFT:
    4553           4 :             nAdj = 0;
    4554           4 :             nAdjBiDi = 2;
    4555           4 :             break;
    4556             :         case SVX_ADJUST_RIGHT:
    4557           0 :             nAdj = 2;
    4558           0 :             nAdjBiDi = 0;
    4559           0 :             break;
    4560             :         case SVX_ADJUST_BLOCKLINE:
    4561             :         case SVX_ADJUST_BLOCK:
    4562           4 :             nAdj = nAdjBiDi = 3;
    4563           4 :             break;
    4564             :         case SVX_ADJUST_CENTER:
    4565           4 :             nAdj = nAdjBiDi = 1;
    4566           4 :             break;
    4567             :         default:
    4568          12 :             return;    // not a supported Attribut
    4569             :     }
    4570             : 
    4571          12 :     if ( 255 != nAdj )        // supported Attribut?
    4572             :     {
    4573          12 :         if ( m_rWW8Export.bWrtWW8 )
    4574             :         {
    4575          12 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PJc );
    4576          12 :             m_rWW8Export.pO->push_back( nAdj );
    4577             : 
    4578             :             /*
    4579             :             Sadly for left to right paragraphs both these values are the same,
    4580             :             for right to left paragraphs the bidi one is the reverse of the
    4581             :             normal one.
    4582             :             */
    4583          12 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PJcExtra ); //bidi version ?
    4584          12 :             bool bBiDiSwap = false;
    4585          12 :             if ( m_rWW8Export.pOutFmtNode )
    4586             :             {
    4587          12 :                 short nDirection = FRMDIR_HORI_LEFT_TOP;
    4588          12 :                 if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtNode ) )
    4589             :                 {
    4590           0 :                     SwPosition aPos(*(const SwCntntNode*)m_rWW8Export.pOutFmtNode);
    4591           0 :                     nDirection = m_rWW8Export.pDoc->GetTextDirection(aPos);
    4592             :                 }
    4593          12 :                 else if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtFmtColl ) )
    4594             :                 {
    4595             :                     const SwTxtFmtColl* pC =
    4596          12 :                         (const SwTxtFmtColl*)m_rWW8Export.pOutFmtNode;
    4597             :                     const SvxFrameDirectionItem &rItem =
    4598          12 :                         ItemGet<SvxFrameDirectionItem>(*pC, RES_FRAMEDIR);
    4599          12 :                     nDirection = rItem.GetValue();
    4600             :                 }
    4601          12 :                 if ( ( nDirection == FRMDIR_HORI_RIGHT_TOP ) ||
    4602           0 :                      ( nDirection == FRMDIR_ENVIRONMENT && Application::GetSettings().GetLayoutRTL() ) )
    4603             :                 {
    4604           0 :                     bBiDiSwap = true;
    4605             :                 }
    4606             :             }
    4607             : 
    4608          12 :             if ( bBiDiSwap )
    4609           0 :                 m_rWW8Export.pO->push_back( nAdjBiDi );
    4610             :             else
    4611          12 :                 m_rWW8Export.pO->push_back( nAdj );
    4612             :         }
    4613             :         else
    4614             :         {
    4615           0 :             m_rWW8Export.pO->push_back( 5 );
    4616           0 :             m_rWW8Export.pO->push_back( nAdj );
    4617             :         }
    4618             :     }
    4619             : }
    4620             : 
    4621          20 : void WW8AttributeOutput::FormatFrameDirection( const SvxFrameDirectionItem& rDirection )
    4622             : {
    4623          20 :     if ( !m_rWW8Export.bWrtWW8 )   //8+ only
    4624          20 :         return;
    4625             : 
    4626          20 :     sal_uInt16 nTextFlow=0;
    4627          20 :     bool bBiDi = false;
    4628          20 :     short nDir = rDirection.GetValue();
    4629             : 
    4630          20 :     if ( nDir == FRMDIR_ENVIRONMENT )
    4631             :     {
    4632           0 :         if ( m_rWW8Export.bOutPageDescs )
    4633           0 :             nDir = m_rWW8Export.GetCurrentPageDirection();
    4634           0 :         else if ( m_rWW8Export.pOutFmtNode )
    4635             :         {
    4636           0 :             if ( m_rWW8Export.bOutFlyFrmAttrs )  //frame
    4637             :             {
    4638             :                 nDir = m_rWW8Export.TrueFrameDirection(
    4639           0 :                     *(const SwFrmFmt*)m_rWW8Export.pOutFmtNode );
    4640             :             }
    4641           0 :             else if ( m_rWW8Export.pOutFmtNode->ISA( SwCntntNode ) )   //pagagraph
    4642             :             {
    4643             :                 const SwCntntNode* pNd =
    4644           0 :                     (const SwCntntNode*)m_rWW8Export.pOutFmtNode;
    4645           0 :                 SwPosition aPos( *pNd );
    4646           0 :                 nDir = m_rWW8Export.pDoc->GetTextDirection( aPos );
    4647             :             }
    4648           0 :             else if ( m_rWW8Export.pOutFmtNode->ISA( SwTxtFmtColl ) )
    4649           0 :                 nDir = FRMDIR_HORI_LEFT_TOP;    //what else can we do :-(
    4650             :         }
    4651             : 
    4652           0 :         if ( nDir == FRMDIR_ENVIRONMENT )
    4653           0 :             nDir = FRMDIR_HORI_LEFT_TOP;    //Set something
    4654             :     }
    4655             : 
    4656          20 :     switch ( nDir )
    4657             :     {
    4658             :         default:
    4659             :             //Can't get an unknown type here
    4660             :             OSL_FAIL("Unknown frame direction");
    4661             :         case FRMDIR_HORI_LEFT_TOP:
    4662          20 :             nTextFlow = 0;
    4663          20 :             break;
    4664             :         case FRMDIR_HORI_RIGHT_TOP:
    4665           0 :             nTextFlow = 0;
    4666           0 :             bBiDi = true;
    4667           0 :             break;
    4668             :         case FRMDIR_VERT_TOP_LEFT:  //word doesn't have this
    4669             :         case FRMDIR_VERT_TOP_RIGHT:
    4670           0 :             nTextFlow = 1;
    4671           0 :             break;
    4672             :     }
    4673             : 
    4674          20 :     if ( m_rWW8Export.bOutPageDescs )
    4675             :     {
    4676          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_STextFlow );
    4677          10 :         m_rWW8Export.InsUInt16( nTextFlow );
    4678          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_SFBiDi );
    4679          10 :         m_rWW8Export.pO->push_back( bBiDi );
    4680             :     }
    4681          10 :     else if ( !m_rWW8Export.bOutFlyFrmAttrs )  //paragraph/style
    4682             :     {
    4683          10 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFBiDi );
    4684          10 :         m_rWW8Export.pO->push_back( bBiDi );
    4685             :     }
    4686             : }
    4687             : 
    4688             : // "Separate paragraphs"
    4689           2 : void WW8AttributeOutput::ParaSplit( const SvxFmtSplitItem& rSplit )
    4690             : {
    4691             :     // sprmPFKeep
    4692           2 :     if ( m_rWW8Export.bWrtWW8 )
    4693           2 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFKeep );
    4694             :     else
    4695           0 :         m_rWW8Export.pO->push_back( 7 );
    4696           2 :     m_rWW8Export.pO->push_back( rSplit.GetValue() ? 0 : 1 );
    4697           2 : }
    4698             : 
    4699             : //  Es wird nur das Item "SvxWidowItem" und nicht die Orphans uebersetzt,
    4700             : //  da es fuer beides im WW nur ein Attribut "Absatzkontrolle" gibt und
    4701             : //  im SW wahrscheinlich vom Anwender immer Beide oder keiner gesetzt werden.
    4702          12 : void WW8AttributeOutput::ParaWidows( const SvxWidowsItem& rWidows )
    4703             : {
    4704             : // sprmPFWidowControl
    4705          12 :     if( m_rWW8Export.bWrtWW8 )
    4706          12 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFWidowControl );
    4707             :     else
    4708           0 :         m_rWW8Export.pO->push_back( 51 );
    4709          12 :     m_rWW8Export.pO->push_back( rWidows.GetValue() ? 1 : 0 );
    4710          12 : }
    4711             : 
    4712             : 
    4713             : class SwWW8WrTabu
    4714             : {
    4715             :     sal_uInt8* pDel;                 // DelArray
    4716             :     sal_uInt8* pAddPos;              // AddPos-Array
    4717             :     sal_uInt8* pAddTyp;              // AddTyp-Array
    4718             :     sal_uInt16 nAdd;            // so viele Tabs kommen hinzu
    4719             :     sal_uInt16 nDel;            // so viele Tabs fallen weg
    4720             : public:
    4721             :     SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax);
    4722             :     ~SwWW8WrTabu();
    4723             : 
    4724             :     void Add(const SvxTabStop &rTS, long nAdjustment);
    4725             :     void Del(const SvxTabStop &rTS, long nAdjustment);
    4726             :     void PutAll(WW8Export& rWW8Wrt);
    4727             : };
    4728             : 
    4729          22 : SwWW8WrTabu::SwWW8WrTabu(sal_uInt16 nDelMax, sal_uInt16 nAddMax)
    4730          22 :     : nAdd(0), nDel(0)
    4731             : {
    4732          22 :     pDel = nDelMax ? new sal_uInt8[nDelMax * 2] : 0;
    4733          22 :     pAddPos = new sal_uInt8[nAddMax * 2];
    4734          22 :     pAddTyp = new sal_uInt8[nAddMax];
    4735          22 : }
    4736             : 
    4737          22 : SwWW8WrTabu::~SwWW8WrTabu()
    4738             : {
    4739          22 :     delete[] pAddTyp;
    4740          22 :     delete[] pAddPos;
    4741          22 :     delete[] pDel;
    4742          22 : }
    4743             : 
    4744             : // Add( const SvxTabStop & rTS ) fuegt einen Tab in die WW-Struktur ein
    4745          18 : void SwWW8WrTabu::Add(const SvxTabStop & rTS, long nAdjustment)
    4746             : {
    4747             :     // Tab-Position eintragen
    4748          18 :     ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
    4749          36 :         pAddPos + (nAdd * 2));
    4750             : 
    4751             :     // Tab-Typ eintragen
    4752          18 :     sal_uInt8 nPara = 0;
    4753          18 :     switch (rTS.GetAdjustment())
    4754             :     {
    4755             :         case SVX_TAB_ADJUST_RIGHT:
    4756          12 :             nPara = 2;
    4757          12 :             break;
    4758             :         case SVX_TAB_ADJUST_CENTER:
    4759           6 :             nPara = 1;
    4760           6 :             break;
    4761             :         case SVX_TAB_ADJUST_DECIMAL:
    4762             :             /*
    4763             :             Theres nothing we can do btw the the decimal seperator has been
    4764             :             customized, but if you think different remember that different
    4765             :             locales have different seperators, i.e. german is a , while english
    4766             :             is a .
    4767             :             */
    4768           0 :             nPara = 3;
    4769           0 :             break;
    4770             :         default:
    4771           0 :             break;
    4772             :     }
    4773             : 
    4774          18 :     switch( rTS.GetFill() )
    4775             :     {
    4776             :         case '.':   // dotted leader
    4777           6 :             nPara |= 1 << 3;
    4778           6 :             break;
    4779             :         case '_':   // Single line leader
    4780           0 :             nPara |= 3 << 3;
    4781           0 :             break;
    4782             :         case '-':   // hyphenated leader
    4783           0 :             nPara |= 2 << 3;
    4784           0 :             break;
    4785             :         case '=':   // heavy line leader
    4786           0 :             nPara |= 4 << 3;
    4787           0 :             break;
    4788             :     }
    4789             : 
    4790          18 :     ByteToSVBT8(nPara, pAddTyp + nAdd);
    4791          18 :     ++nAdd;
    4792          18 : }
    4793             : 
    4794             : // Del( const SvxTabStop & rTS ) fuegt einen zu loeschenden Tab
    4795             : // in die WW-Struktur ein
    4796           0 : void SwWW8WrTabu::Del(const SvxTabStop &rTS, long nAdjustment)
    4797             : {
    4798             :     // Tab-Position eintragen
    4799           0 :     ShortToSVBT16(msword_cast<sal_Int16>(rTS.GetTabPos() + nAdjustment),
    4800           0 :         pDel + (nDel * 2));
    4801           0 :     ++nDel;
    4802           0 : }
    4803             : 
    4804             : //  PutAll( WW8Export& rWW8Wrt ) schreibt das Attribut nach rWrt.pO
    4805          22 : void SwWW8WrTabu::PutAll(WW8Export& rWrt)
    4806             : {
    4807          22 :     if (!nAdd && !nDel) //It its a no-op
    4808          32 :         return;
    4809             :     OSL_ENSURE(nAdd <= 255, "more than 255 added tabstops ?");
    4810             :     OSL_ENSURE(nDel <= 255, "more than 244 removed tabstops ?");
    4811          12 :     if (nAdd > 255)
    4812           0 :         nAdd = 255;
    4813          12 :     if (nDel > 255)
    4814           0 :         nDel = 255;
    4815             : 
    4816          12 :     sal_uInt16 nSiz = 2 * nDel + 3 * nAdd + 2;
    4817          12 :     if (nSiz > 255)
    4818           0 :         nSiz = 255;
    4819             : 
    4820          12 :     if (rWrt.bWrtWW8)
    4821          12 :         rWrt.InsUInt16(NS_sprm::LN_PChgTabsPapx);
    4822             :     else
    4823           0 :         rWrt.pO->push_back(15);
    4824             :     // cch eintragen
    4825          12 :     rWrt.pO->push_back(msword_cast<sal_uInt8>(nSiz));
    4826             :     // DelArr schreiben
    4827          12 :     rWrt.pO->push_back(msword_cast<sal_uInt8>(nDel));
    4828          12 :     rWrt.OutSprmBytes(pDel, nDel * 2);
    4829             :     // InsArr schreiben
    4830          12 :     rWrt.pO->push_back(msword_cast<sal_uInt8>(nAdd));
    4831          12 :     rWrt.OutSprmBytes(pAddPos, 2 * nAdd);         // AddPosArray
    4832          12 :     rWrt.OutSprmBytes(pAddTyp, nAdd);             // AddTypArray
    4833             : }
    4834             : 
    4835             : 
    4836           8 : static void ParaTabStopAdd( WW8Export& rWrt, const SvxTabStopItem& rTStops,
    4837             :     long nLParaMgn )
    4838             : {
    4839           8 :     SwWW8WrTabu aTab( 0, rTStops.Count());
    4840             : 
    4841          16 :     for( sal_uInt16 n = 0; n < rTStops.Count(); n++ )
    4842             :     {
    4843           8 :         const SvxTabStop& rTS = rTStops[n];
    4844             :         // Def-Tabs ignorieren
    4845           8 :         if (SVX_TAB_ADJUST_DEFAULT != rTS.GetAdjustment())
    4846           0 :             aTab.Add(rTS, nLParaMgn);
    4847             :     }
    4848           8 :     aTab.PutAll( rWrt );
    4849           8 : }
    4850             : 
    4851           0 : static bool lcl_IsEqual(long nOneLeft, const SvxTabStop &rOne,
    4852             :     long nTwoLeft, const SvxTabStop &rTwo)
    4853             : {
    4854             :     return(
    4855             :             nOneLeft == nTwoLeft &&
    4856           0 :             rOne.GetAdjustment() == rTwo.GetAdjustment() &&
    4857           0 :             rOne.GetDecimal() == rTwo.GetDecimal() &&
    4858           0 :             rOne.GetFill() == rTwo.GetFill()
    4859           0 :           );
    4860             : }
    4861             : 
    4862          14 : static void ParaTabStopDelAdd( WW8Export& rWrt, const SvxTabStopItem& rTStyle,
    4863             :     long nLStypeMgn, const SvxTabStopItem& rTNew, long nLParaMgn )
    4864             : {
    4865          14 :     SwWW8WrTabu aTab(rTStyle.Count(), rTNew.Count());
    4866             : 
    4867          14 :     sal_uInt16 nO = 0;      // rTStyle Index
    4868          14 :     sal_uInt16 nN = 0;      // rTNew Index
    4869             : 
    4870          32 :     do {
    4871             :         const SvxTabStop* pTO;
    4872             :         long nOP;
    4873          46 :         if( nO < rTStyle.Count() )                  // alt noch nicht am Ende ?
    4874             :         {
    4875          14 :             pTO = &rTStyle[ nO ];
    4876          14 :             nOP = pTO->GetTabPos() + nLStypeMgn;
    4877          14 :             if( SVX_TAB_ADJUST_DEFAULT == pTO->GetAdjustment() )
    4878             :             {
    4879          14 :                 nO++;                                // Default-Tab ignorieren
    4880          14 :                 continue;
    4881             :             }
    4882             :         }
    4883             :         else
    4884             :         {
    4885          32 :             pTO = 0;
    4886          32 :             nOP = LONG_MAX;
    4887             :         }
    4888             : 
    4889             :         const SvxTabStop* pTN;
    4890             :         long nNP;
    4891          32 :         if( nN < rTNew.Count() )                    // neu noch nicht am Ende
    4892             :         {
    4893          18 :             pTN = &rTNew[ nN ];
    4894          18 :             nNP = pTN->GetTabPos() + nLParaMgn;
    4895          18 :             if( SVX_TAB_ADJUST_DEFAULT == pTN->GetAdjustment() )
    4896             :             {
    4897           0 :                 nN++;                               // Default-Tab ignorieren
    4898           0 :                 continue;
    4899             :             }
    4900             :         }
    4901             :         else
    4902             :         {
    4903          14 :             pTN = 0;
    4904          14 :             nNP = LONG_MAX;
    4905             :         }
    4906             : 
    4907          32 :         if( nOP == LONG_MAX && nNP == LONG_MAX )
    4908          14 :             break;                                  // alles fertig
    4909             : 
    4910          18 :         if( nOP < nNP )                             // naechster Tab ist alt
    4911             :         {
    4912           0 :             aTab.Del(*pTO, nLStypeMgn);             // muss geloescht werden
    4913           0 :             nO++;
    4914             :         }
    4915          18 :         else if( nNP < nOP )                        // naechster Tab ist neu
    4916             :         {
    4917          18 :             aTab.Add(*pTN, nLParaMgn);              // muss eigefuegt werden
    4918          18 :             nN++;
    4919             :         }
    4920           0 :         else if (lcl_IsEqual(nOP, *pTO, nNP, *pTN)) // Tabs sind gleich:
    4921             :         {
    4922           0 :             nO++;                                   // nichts zu tun
    4923           0 :             nN++;
    4924             :         }
    4925             :         else                                        // Tabs selbe Pos, diff Typ
    4926             :         {
    4927           0 :             aTab.Del(*pTO, nLStypeMgn);             // alten loeschen
    4928           0 :             aTab.Add(*pTN, nLParaMgn);              // neuen einfuegen
    4929           0 :             nO++;
    4930           0 :             nN++;
    4931             :         }
    4932             :     } while( 1 );
    4933             : 
    4934          14 :     aTab.PutAll( rWrt );
    4935          14 : }
    4936             : 
    4937          22 : void WW8AttributeOutput::ParaTabStop( const SvxTabStopItem& rTabStops )
    4938             : {
    4939          22 :     bool bTabsRelativeToIndex = m_rWW8Export.pCurPam->GetDoc()->get( IDocumentSettingAccess::TABS_RELATIVE_TO_INDENT );
    4940          22 :     long nCurrentLeft = 0;
    4941             : 
    4942          22 :     if ( bTabsRelativeToIndex )
    4943             :     {
    4944           2 :         const SfxPoolItem* pLR = m_rWW8Export.HasItem( RES_LR_SPACE );
    4945             : 
    4946           2 :         if ( pLR != NULL )
    4947           0 :             nCurrentLeft = ((const SvxLRSpaceItem*)pLR)->GetTxtLeft();
    4948             :     }
    4949             : 
    4950             :     // #i100264#
    4951          36 :     if ( m_rWW8Export.bStyDef &&
    4952             :          m_rWW8Export.pCurrentStyle != NULL &&
    4953          14 :          m_rWW8Export.pCurrentStyle->DerivedFrom() != NULL )
    4954             :     {
    4955          14 :         SvxTabStopItem aTabs( 0, 0, SVX_TAB_ADJUST_DEFAULT, RES_PARATR_TABSTOP );
    4956          14 :         const SwFmt *pParentStyle = m_rWW8Export.pCurrentStyle->DerivedFrom();
    4957          14 :         const SvxTabStopItem* pParentTabs = HasItem<SvxTabStopItem>( pParentStyle->GetAttrSet(), RES_PARATR_TABSTOP );
    4958          14 :         if ( pParentTabs )
    4959             :         {
    4960          14 :             aTabs.Insert( pParentTabs );
    4961             :         }
    4962             : 
    4963          14 :         ParaTabStopDelAdd( m_rWW8Export, aTabs, 0, rTabStops, 0 );
    4964          36 :         return;
    4965             :     }
    4966             : 
    4967             :     // StyleDef -> "einfach" eintragen || keine Style-Attrs -> dito
    4968           8 :     const SvxTabStopItem* pStyleTabs = 0;
    4969           8 :     if ( !m_rWW8Export.bStyDef && m_rWW8Export.pStyAttr )
    4970             :     {
    4971             :         pStyleTabs =
    4972           0 :             HasItem<SvxTabStopItem>( *m_rWW8Export.pStyAttr, RES_PARATR_TABSTOP );
    4973             :     }
    4974             : 
    4975           8 :     if ( !pStyleTabs )
    4976           8 :         ParaTabStopAdd(m_rWW8Export, rTabStops, nCurrentLeft);
    4977             :     else
    4978             :     {
    4979           0 :         long nStyleLeft = 0;
    4980             : 
    4981           0 :         if (bTabsRelativeToIndex)
    4982             :         {
    4983             :             const SvxLRSpaceItem &rStyleLR =
    4984           0 :             ItemGet<SvxLRSpaceItem>(*m_rWW8Export.pStyAttr, RES_LR_SPACE);
    4985           0 :             nStyleLeft = rStyleLR.GetTxtLeft();
    4986             :         }
    4987             : 
    4988             :         ParaTabStopDelAdd(m_rWW8Export, *pStyleTabs, nStyleLeft, rTabStops,
    4989           0 :             nCurrentLeft);
    4990             :     }
    4991             : }
    4992             : 
    4993             : //-----------------------------------------------------------------------
    4994             : 
    4995        7452 : void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
    4996             : {
    4997             :     // FIXME maybe use 'item_cast', like 'item_cast<SvxCharHiddenItem>( rHt )'?
    4998        7452 :     switch ( rHt.Which() )
    4999             :     {
    5000             :         case RES_CHRATR_CASEMAP:
    5001           0 :             CharCaseMap( static_cast< const SvxCaseMapItem& >( rHt ) );
    5002           0 :             break;
    5003             :         case RES_CHRATR_COLOR:
    5004         120 :             CharColor( static_cast< const SvxColorItem& >( rHt ) );
    5005         120 :             break;
    5006             :         case RES_CHRATR_CONTOUR:
    5007           0 :             CharContour( static_cast< const SvxContourItem& >( rHt ) );
    5008           0 :             break;
    5009             :         case RES_CHRATR_CROSSEDOUT:
    5010           0 :             CharCrossedOut( static_cast< const SvxCrossedOutItem& >( rHt ) );
    5011           0 :             break;
    5012             :         case RES_CHRATR_ESCAPEMENT:
    5013          12 :             CharEscapement( static_cast< const SvxEscapementItem& >( rHt ) );
    5014          12 :             break;
    5015             :         case RES_CHRATR_FONT:
    5016         534 :             CharFont( static_cast< const SvxFontItem& >( rHt ) );
    5017         534 :             break;
    5018             :         case RES_CHRATR_FONTSIZE:
    5019         418 :             CharFontSize( static_cast< const SvxFontHeightItem& >( rHt ) );
    5020         418 :             break;
    5021             :         case RES_CHRATR_KERNING:
    5022           0 :             CharKerning( static_cast< const SvxKerningItem& >( rHt ) );
    5023           0 :             break;
    5024             :         case RES_CHRATR_LANGUAGE:
    5025         228 :             CharLanguage( static_cast< const SvxLanguageItem& >( rHt ) );
    5026         228 :             break;
    5027             :         case RES_CHRATR_POSTURE:
    5028         118 :             CharPosture( static_cast< const SvxPostureItem& >( rHt ) );
    5029         118 :             break;
    5030             :         case RES_CHRATR_SHADOWED:
    5031           0 :             CharShadow( static_cast< const SvxShadowedItem& >( rHt ) );
    5032           0 :             break;
    5033             :         case RES_CHRATR_UNDERLINE:
    5034           8 :             CharUnderline( static_cast< const SvxUnderlineItem& >( rHt ) );
    5035           8 :             break;
    5036             :         case RES_CHRATR_WEIGHT:
    5037          16 :             CharWeight( static_cast< const SvxWeightItem& >( rHt ) );
    5038          16 :             break;
    5039             :         case RES_CHRATR_AUTOKERN:
    5040         108 :             CharAutoKern( static_cast< const SvxAutoKernItem& >( rHt ) );
    5041         108 :             break;
    5042             :         case RES_CHRATR_BLINK:
    5043           0 :             CharAnimatedText( static_cast< const SvxBlinkItem& >( rHt ) );
    5044           0 :             break;
    5045             :         case RES_CHRATR_BACKGROUND:
    5046           0 :             CharBackground( static_cast< const SvxBrushItem& >( rHt ) );
    5047           0 :             break;
    5048             : 
    5049             :         case RES_CHRATR_CJK_FONT:
    5050         514 :             CharFontCJK( static_cast< const SvxFontItem& >( rHt ) );
    5051         514 :             break;
    5052             :         case RES_CHRATR_CJK_FONTSIZE:
    5053           0 :             CharFontSizeCJK( static_cast< const SvxFontHeightItem& >( rHt ) );
    5054           0 :             break;
    5055             :         case RES_CHRATR_CJK_LANGUAGE:
    5056         124 :             CharLanguageCJK( static_cast< const SvxLanguageItem& >( rHt ) );
    5057         124 :             break;
    5058             :         case RES_CHRATR_CJK_POSTURE:
    5059           0 :             CharPostureCJK( static_cast< const SvxPostureItem& >( rHt ) );
    5060           0 :             break;
    5061             :         case RES_CHRATR_CJK_WEIGHT:
    5062           0 :             CharWeightCJK( static_cast< const SvxWeightItem& >( rHt ) );
    5063           0 :             break;
    5064             : 
    5065             :         case RES_CHRATR_CTL_FONT:
    5066         560 :             CharFontCTL( static_cast< const SvxFontItem& >( rHt ) );
    5067         560 :             break;
    5068             :         case RES_CHRATR_CTL_FONTSIZE:
    5069         408 :             CharFontSizeCTL( static_cast< const SvxFontHeightItem& >( rHt ) );
    5070         408 :             break;
    5071             :         case RES_CHRATR_CTL_LANGUAGE:
    5072         124 :             CharLanguageCTL( static_cast< const SvxLanguageItem& >( rHt ) );
    5073         124 :             break;
    5074             :         case RES_CHRATR_CTL_POSTURE:
    5075         118 :             CharPostureCTL( static_cast< const SvxPostureItem& >( rHt ) );
    5076         118 :             break;
    5077             :         case RES_CHRATR_CTL_WEIGHT:
    5078          16 :             CharWeightCTL( static_cast< const SvxWeightItem& >( rHt ) );
    5079          16 :             break;
    5080             : 
    5081             :         case RES_CHRATR_ROTATE:
    5082           0 :             CharRotate( static_cast< const SvxCharRotateItem& >( rHt ) );
    5083           0 :             break;
    5084             :         case RES_CHRATR_EMPHASIS_MARK:
    5085           0 :             CharEmphasisMark( static_cast< const SvxEmphasisMarkItem& >( rHt ) );
    5086           0 :             break;
    5087             :         case RES_CHRATR_TWO_LINES:
    5088           0 :             CharTwoLines( static_cast< const SvxTwoLinesItem& >( rHt ) );
    5089           0 :             break;
    5090             :         case RES_CHRATR_SCALEW:
    5091           0 :             CharScaleWidth( static_cast< const SvxCharScaleWidthItem& >( rHt ) );
    5092           0 :             break;
    5093             :         case RES_CHRATR_RELIEF:
    5094           0 :             CharRelief( static_cast< const SvxCharReliefItem& >( rHt ) );
    5095           0 :             break;
    5096             :         case RES_CHRATR_HIDDEN:
    5097           0 :             CharHidden( static_cast< const SvxCharHiddenItem& >( rHt ) );
    5098           0 :             break;
    5099             : 
    5100             :         case RES_TXTATR_INETFMT:
    5101           6 :             TextINetFormat( static_cast< const SwFmtINetFmt& >( rHt ) );
    5102           6 :             break;
    5103             :         case RES_TXTATR_CHARFMT:
    5104           2 :             TextCharFormat( static_cast< const SwFmtCharFmt& >( rHt ) );
    5105           2 :             break;
    5106             :         case RES_TXTATR_FIELD:
    5107           4 :             TextField( static_cast< const SwFmtFld& >( rHt ) );
    5108           4 :             break;
    5109             :         case RES_TXTATR_FLYCNT:
    5110         144 :             TextFlyContent( static_cast< const SwFmtFlyCnt& >( rHt ) );
    5111         144 :             break;
    5112             :         case RES_TXTATR_FTN:
    5113           4 :             TextFootnote( static_cast< const SwFmtFtn& >( rHt ) );
    5114           4 :             break;
    5115             : 
    5116             :         case RES_PARATR_LINESPACING:
    5117          40 :             ParaLineSpacing( static_cast< const SvxLineSpacingItem& >( rHt ) );
    5118          40 :             break;
    5119             :         case RES_PARATR_ADJUST:
    5120          12 :             ParaAdjust( static_cast< const SvxAdjustItem& >( rHt ) );
    5121          12 :             break;
    5122             :         case RES_PARATR_SPLIT:
    5123           2 :             ParaSplit( static_cast< const SvxFmtSplitItem& >( rHt ) );
    5124           2 :             break;
    5125             :         case RES_PARATR_WIDOWS:
    5126         118 :             ParaWidows( static_cast< const SvxWidowsItem& >( rHt ) );
    5127         118 :             break;
    5128             :         case RES_PARATR_TABSTOP:
    5129         126 :             ParaTabStop( static_cast< const SvxTabStopItem& >( rHt ) );
    5130         126 :             break;
    5131             :         case RES_PARATR_HYPHENZONE:
    5132         116 :             ParaHyphenZone( static_cast< const SvxHyphenZoneItem& >( rHt ) );
    5133         116 :             break;
    5134             :         case RES_PARATR_NUMRULE:
    5135           6 :             ParaNumRule( static_cast< const SwNumRuleItem& >( rHt ) );
    5136           6 :             break;
    5137             :         case RES_PARATR_SCRIPTSPACE:
    5138          20 :             ParaScriptSpace( static_cast< const SfxBoolItem& >( rHt ) );
    5139          20 :             break;
    5140             :         case RES_PARATR_HANGINGPUNCTUATION:
    5141          22 :             ParaHangingPunctuation( static_cast< const SfxBoolItem& >( rHt ) );
    5142          22 :             break;
    5143             :         case RES_PARATR_FORBIDDEN_RULES:
    5144          20 :             ParaForbiddenRules( static_cast< const SfxBoolItem& >( rHt ) );
    5145          20 :             break;
    5146             :         case RES_PARATR_VERTALIGN:
    5147           0 :             ParaVerticalAlign( static_cast< const SvxParaVertAlignItem& >( rHt ) );
    5148           0 :             break;
    5149             :         case RES_PARATR_SNAPTOGRID:
    5150           0 :             ParaSnapToGrid( static_cast< const SvxParaGridItem& >( rHt ) );
    5151           0 :             break;
    5152             : 
    5153             :         case RES_FRM_SIZE:
    5154         194 :             FormatFrameSize( static_cast< const SwFmtFrmSize& >( rHt ) );
    5155         194 :             break;
    5156             :         case RES_PAPER_BIN:
    5157           0 :             FormatPaperBin( static_cast< const SvxPaperBinItem& >( rHt ) );
    5158           0 :             break;
    5159             :         case RES_LR_SPACE:
    5160         224 :             FormatLRSpace( static_cast< const SvxLRSpaceItem& >( rHt ) );
    5161         224 :             break;
    5162             :         case RES_UL_SPACE:
    5163         664 :             FormatULSpace( static_cast< const SvxULSpaceItem& >( rHt ) );
    5164         664 :             break;
    5165             :         case RES_PAGEDESC:
    5166         100 :             FormatPageDescription( static_cast< const SwFmtPageDesc& >( rHt ) );
    5167         100 :             break;
    5168             :         case RES_BREAK:
    5169          16 :             FormatBreak( static_cast< const SvxFmtBreakItem& >( rHt ) );
    5170          16 :             break;
    5171             :         case RES_SURROUND:
    5172          12 :             FormatSurround( static_cast< const SwFmtSurround& >( rHt ) );
    5173          12 :             break;
    5174             :         case RES_VERT_ORIENT:
    5175          12 :             FormatVertOrientation( static_cast< const SwFmtVertOrient& >( rHt ) );
    5176          12 :             break;
    5177             :         case RES_HORI_ORIENT:
    5178          12 :             FormatHorizOrientation( static_cast< const SwFmtHoriOrient& >( rHt ) );
    5179          12 :             break;
    5180             :         case RES_ANCHOR:
    5181          12 :             FormatAnchor( static_cast< const SwFmtAnchor& >( rHt ) );
    5182          12 :             break;
    5183             :         case RES_BACKGROUND:
    5184           6 :             FormatBackground( static_cast< const SvxBrushItem& >( rHt ) );
    5185           6 :             break;
    5186             :         case RES_BOX:
    5187          16 :             FormatBox( static_cast< const SvxBoxItem& >( rHt ) );
    5188          16 :             break;
    5189             :         case RES_COL:
    5190           0 :             FormatColumns( static_cast< const SwFmtCol& >( rHt ) );
    5191           0 :             break;
    5192             :         case RES_KEEP:
    5193         116 :             FormatKeep( static_cast< const SvxFmtKeepItem& >( rHt ) );
    5194         116 :             break;
    5195             :         case RES_TEXTGRID:
    5196         156 :             FormatTextGrid( static_cast< const SwTextGridItem& >( rHt ) );
    5197         156 :             break;
    5198             :         case RES_LINENUMBER:
    5199         238 :             FormatLineNumbering( static_cast< const SwFmtLineNumber& >( rHt ) );
    5200         238 :             break;
    5201             :         case RES_FRAMEDIR:
    5202         248 :             FormatFrameDirection( static_cast< const SvxFrameDirectionItem& >( rHt ) );
    5203         248 :             break;
    5204             : 
    5205             :         default:
    5206             :             OSL_TRACE("Unhandled SfxPoolItem with id %d.", rHt.Which() );
    5207        1358 :             break;
    5208             :     }
    5209        7452 : }
    5210             : 
    5211          60 : void AttributeOutputBase::OutputStyleItemSet( const SfxItemSet& rSet, sal_Bool bDeep, sal_Bool bTestForDefault )
    5212             : {
    5213             :     // based on OutputItemSet() from wrt_fn.cxx
    5214             : 
    5215          60 :     const SfxItemPool& rPool = *rSet.GetPool();
    5216          60 :     const SfxItemSet* pSet = &rSet;
    5217          60 :     if ( !pSet->Count() )
    5218             :     {
    5219           0 :         if ( !bDeep )
    5220             :             return;
    5221             : 
    5222           0 :         while ( 0 != ( pSet = pSet->GetParent() ) && !pSet->Count() )
    5223             :             ;
    5224             : 
    5225           0 :         if ( !pSet )
    5226             :             return;
    5227             :     }
    5228             : 
    5229             :     const SfxPoolItem* pItem;
    5230          60 :     if ( !bDeep || !pSet->GetParent() )
    5231             :     {
    5232             :         OSL_ENSURE( rSet.Count(), "Wurde doch schon behandelt oder?" );
    5233           0 :         SfxItemIter aIter( *pSet );
    5234           0 :         pItem = aIter.GetCurItem();
    5235           0 :         do {
    5236           0 :             OutputItem( *pItem );
    5237           0 :         } while ( !aIter.IsAtEnd() && 0 != ( pItem = aIter.NextItem() ) );
    5238             :     }
    5239             :     else
    5240             :     {
    5241          60 :         SfxWhichIter aIter( *pSet );
    5242          60 :         sal_uInt16 nWhich = aIter.FirstWhich();
    5243        2640 :         while ( nWhich )
    5244             :         {
    5245        2520 :             if ( SFX_ITEM_SET == pSet->GetItemState( nWhich, bDeep, &pItem ) &&
    5246             :                  ( !bTestForDefault ||
    5247           0 :                    *pItem != rPool.GetDefaultItem( nWhich ) ||
    5248           0 :                    ( pSet->GetParent() && *pItem != pSet->GetParent()->Get( nWhich ) ) ) )
    5249             :             {
    5250         406 :                 OutputItem( *pItem );
    5251             :             }
    5252        2520 :             nWhich = aIter.NextWhich();
    5253          60 :         }
    5254             :     }
    5255          36 : }
    5256             : 
    5257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10