LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - wrtww8.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 963 1821 52.9 %
Date: 2012-08-25 Functions: 102 144 70.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 754 2541 29.7 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <iostream>
      31                 :            : 
      32                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      33                 :            : #include <com/sun/star/embed/XStorage.hpp>
      34                 :            : #include <unotools/ucbstreamhelper.hxx>
      35                 :            : 
      36                 :            : #include <algorithm>
      37                 :            : 
      38                 :            : #include <hintids.hxx>
      39                 :            : #include <string.h>             // memcpy()
      40                 :            : #include <osl/endian.h>
      41                 :            : #include <docsh.hxx>
      42                 :            : 
      43                 :            : #include <unotools/fltrcfg.hxx>
      44                 :            : #include <vcl/salbtype.hxx>
      45                 :            : #include <sot/storage.hxx>
      46                 :            : #include <svl/zformat.hxx>
      47                 :            : #include <sfx2/docinf.hxx>
      48                 :            : #include <editeng/tstpitem.hxx>
      49                 :            : #include <svx/svdmodel.hxx>
      50                 :            : #include <svx/svdpage.hxx>
      51                 :            : #include <editeng/hyznitem.hxx>
      52                 :            : #include <editeng/langitem.hxx>
      53                 :            : #include <filter/msfilter/msoleexp.hxx>
      54                 :            : #include <editeng/lrspitem.hxx>
      55                 :            : #include <editeng/ulspitem.hxx>
      56                 :            : #include <editeng/boxitem.hxx>
      57                 :            : #include <editeng/brshitem.hxx>
      58                 :            : #include <swtypes.hxx>
      59                 :            : #include <swrect.hxx>
      60                 :            : #include <swtblfmt.hxx>
      61                 :            : #include <txatbase.hxx>
      62                 :            : #include <fmtcntnt.hxx>
      63                 :            : #include <fmtpdsc.hxx>
      64                 :            : #include <fmtrowsplt.hxx>
      65                 :            : #include <frmatr.hxx>
      66                 :            : #include <doc.hxx>
      67                 :            : #include <docary.hxx>
      68                 :            : #include <pam.hxx>
      69                 :            : #include <ndtxt.hxx>
      70                 :            : #include <shellio.hxx>
      71                 :            : #include <docstat.hxx>
      72                 :            : #include <pagedesc.hxx>
      73                 :            : #include <IMark.hxx>
      74                 :            : #include <swtable.hxx>
      75                 :            : #include <wrtww8.hxx>
      76                 :            : #include <ww8par.hxx>
      77                 :            : #include <fltini.hxx>
      78                 :            : #include <swmodule.hxx>
      79                 :            : #include <section.hxx>
      80                 :            : #include <swfltopt.hxx>
      81                 :            : #include <fmtinfmt.hxx>
      82                 :            : #include <txtinet.hxx>
      83                 :            : #include <fmturl.hxx>
      84                 :            : #include <fesh.hxx>
      85                 :            : #include <svtools/imap.hxx>
      86                 :            : #include <svtools/imapobj.hxx>
      87                 :            : #include <tools/urlobj.hxx>
      88                 :            : #include <mdiexp.hxx>           // Progress
      89                 :            : #include <statstr.hrc>          // ResId fuer Statusleiste
      90                 :            : #include <fmtline.hxx>
      91                 :            : #include <fmtfsize.hxx>
      92                 :            : #include <comphelper/extract.hxx>
      93                 :            : #include <comphelper/stlunosequence.hxx>
      94                 :            : #include <comphelper/string.hxx>
      95                 :            : #include <writerfilter/doctok/sprmids.hxx>
      96                 :            : 
      97                 :            : #include "writerhelper.hxx"
      98                 :            : #include "writerwordglue.hxx"
      99                 :            : #include "ww8attributeoutput.hxx"
     100                 :            : 
     101                 :            : #include <IDocumentMarkAccess.hxx>
     102                 :            : #include <xmloff/odffields.hxx>
     103                 :            : 
     104                 :            : #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
     105                 :            : #include <com/sun/star/document/XDocumentProperties.hpp>
     106                 :            : 
     107                 :            : #include "dbgoutsw.hxx"
     108                 :            : 
     109                 :            : #include <sfx2/docfile.hxx>
     110                 :            : #include <sfx2/request.hxx>
     111                 :            : #include <sfx2/frame.hxx>
     112                 :            : #include <svl/stritem.hxx>
     113                 :            : #include <unotools/tempfile.hxx>
     114                 :            : #include <filter/msfilter/mscodec.hxx>
     115                 :            : #include <filter/msfilter/svxmsbas.hxx>
     116                 :            : #include <osl/time.h>
     117                 :            : #include <rtl/random.h>
     118                 :            : #include "WW8Sttbf.hxx"
     119                 :            : #include "WW8FibData.hxx"
     120                 :            : 
     121                 :            : using namespace sw::util;
     122                 :            : using namespace sw::types;
     123                 :            : 
     124                 :            : /** FKP - Formatted disK Page
     125                 :            : */
     126                 :            : class WW8_WrFkp
     127                 :            : {
     128                 :            :     sal_uInt8* pFkp;         // gesamter Fkp ( zuerst nur FCs und Sprms )
     129                 :            :     sal_uInt8* pOfs;         // Pointer auf Offset-Bereich, spaeter nach pFkp kopiert
     130                 :            :     ePLCFT ePlc;
     131                 :            :     short nStartGrp;    // ab hier grpprls
     132                 :            :     short nOldStartGrp;
     133                 :            :     sal_uInt8 nItemSize;
     134                 :            :     sal_uInt8 nIMax;         // Anzahl der Eintrags-Paare
     135                 :            :     sal_uInt8 nOldVarLen;
     136                 :            :     sal_uInt8 nMark;
     137                 :            :     bool bCombined;     // true : Einfuegen verboten
     138                 :            : 
     139                 :            :     sal_uInt8 SearchSameSprm( sal_uInt16 nVarLen, const sal_uInt8* pSprms );
     140                 :            : public:
     141                 :            :     WW8_WrFkp(ePLCFT ePl, WW8_FC nStartFc, bool bWrtWW8);
     142                 :            :     ~WW8_WrFkp();
     143                 :            :     bool Append( WW8_FC nEndFc, sal_uInt16 nVarLen = 0, const sal_uInt8* pSprms = 0 );
     144                 :            :     bool Combine();
     145                 :            :     void Write( SvStream& rStrm, SwWW8WrGrf& rGrf );
     146                 :            : 
     147                 :        201 :     bool IsEqualPos(WW8_FC nEndFc) const
     148 [ +  - ][ +  + ]:        201 :     {   return !bCombined && nIMax && nEndFc == ((sal_Int32*)pFkp)[nIMax]; }
                 [ +  + ]
     149                 :            :     void MergeToNew( short& rVarLen, sal_uInt8 *& pNewSprms );
     150                 :         75 :     bool IsEmptySprm() const
     151 [ +  - ][ +  + ]:         75 :     {   return !bCombined && nIMax && !nOldVarLen;  }
                 [ +  + ]
     152                 :         45 :     void SetNewEnd( WW8_FC nEnd )
     153                 :         45 :     {   ((sal_Int32*)pFkp)[nIMax] = nEnd; }
     154                 :            : 
     155                 :            : #ifdef __WW8_NEEDS_COPY
     156                 :            :     WW8_FC GetStartFc() const;
     157                 :            :     WW8_FC GetEndFc() const;
     158                 :            : #else
     159                 :            :     WW8_FC GetStartFc() const { return ((sal_Int32*)pFkp)[0]; };
     160                 :            :     WW8_FC GetEndFc() const { return ((sal_Int32*)pFkp)[nIMax]; };
     161                 :            : #endif // defined __WW8_NEEDS_COPY
     162                 :            : 
     163                 :            :     sal_uInt8 *CopyLastSprms(sal_uInt8 &rLen, bool bVer8);
     164                 :            : };
     165                 :            : 
     166                 :            : 
     167                 :            : // -------------------------------------------------------------------------
     168                 :            : // class WW8_WrPc sammelt alle Piece-Eintraege fuer ein Piece
     169                 :            : // -------------------------------------------------------------------------
     170                 :            : 
     171                 :            : class WW8_WrPc
     172                 :            : {
     173                 :            :     WW8_CP nStartCp;                    // Start ZeichenPosition vom Text
     174                 :            :     WW8_FC nStartFc;                    // Start File Position vom Text
     175                 :            :     sal_uInt16 nStatus;                     // Absatzende im Piece ?
     176                 :            : 
     177                 :            : public:
     178                 :          9 :     WW8_WrPc(WW8_FC nSFc, WW8_CP nSCp )
     179                 :          9 :         : nStartCp( nSCp ), nStartFc( nSFc ), nStatus( 0x0040 )
     180                 :          9 :     {}
     181                 :            : 
     182                 :        117 :     void SetStatus()                { nStatus = 0x0050; }
     183                 :          9 :     sal_uInt16 GetStatus()  const       { return nStatus; }
     184                 :        180 :     WW8_CP GetStartCp() const       { return nStartCp; }
     185                 :          9 :     WW8_FC GetStartFc() const       { return nStartFc; }
     186                 :            : };
     187                 :            : 
     188                 :            : class WW8_WrtBookmarks
     189                 :            : {
     190                 :            : private:
     191                 :            :     //! Holds information about a single bookmark.
     192                 :         33 :     struct BookmarkInfo {
     193                 :            :         sal_uLong  startPos; //!< Starting character position.
     194                 :            :         sal_uLong  endPos;   //!< Ending character position.
     195                 :            :         bool   isField;  //!< True if the bookmark is in a field result.
     196                 :            :         String name;     //!< Name of this bookmark.
     197                 :          6 :         inline BookmarkInfo(sal_uLong start, sal_uLong end, bool isFld, const String& bkName) : startPos(start), endPos(end), isField(isFld), name(bkName) {};
     198                 :            :         //! Operator < is defined purely for sorting.
     199                 :          6 :         inline bool operator<(const BookmarkInfo &other) const { return startPos < other.startPos; }
     200                 :            :     };
     201                 :            :     std::vector<BookmarkInfo> aBookmarks;
     202                 :            :     typedef std::vector<BookmarkInfo>::iterator BkmIter;
     203                 :            : 
     204                 :            :     //! Return the position in aBookmarks where the string rNm can be found.
     205                 :            :     BkmIter GetPos( const String& rNm );
     206                 :            : 
     207                 :            :     //No copying
     208                 :            :     WW8_WrtBookmarks(const WW8_WrtBookmarks&);
     209                 :            :     WW8_WrtBookmarks& operator=(const WW8_WrtBookmarks&);
     210                 :            : public:
     211                 :            :     WW8_WrtBookmarks();
     212                 :            :     ~WW8_WrtBookmarks();
     213                 :            : 
     214                 :            :     //! Add a new bookmark to the list OR add an end position to an existing bookmark.
     215                 :            :     void Append( WW8_CP nStartCp, const String& rNm, const ::sw::mark::IMark* pBkmk=NULL );
     216                 :            :     //! Write out bookmarks to file.
     217                 :            :     void Write( WW8Export& rWrt );
     218                 :            :     //! Move existing field marks from one position to another.
     219                 :            :     void MoveFieldMarks(sal_uLong nFrom,sal_uLong nTo);
     220                 :            : 
     221                 :            : };
     222                 :            : 
     223                 :            : #define ANZ_DEFAULT_STYLES 16
     224                 :            : 
     225                 :            : // die Namen der StorageStreams
     226                 :            : #define sMainStream rtl::OUString("WordDocument")
     227                 :            : #define sCompObj rtl::OUString("\1CompObj")
     228                 :            : 
     229                 :          9 : static void WriteDop( WW8Export& rWrt )
     230                 :            : {
     231                 :          9 :     WW8Dop& rDop = *rWrt.pDop;
     232                 :            : 
     233                 :            :     // i#78951#, store the value of  unknown compatability options
     234         [ +  - ]:          9 :     rDop.SetCompatabilityOptions( rWrt.pDoc->Getn32DummyCompatabilityOptions1());
     235         [ +  - ]:          9 :     rDop.SetCompatabilityOptions2( rWrt.pDoc->Getn32DummyCompatabilityOptions2());
     236                 :            : 
     237         [ +  - ]:          9 :     rDop.fNoLeading = !rWrt.pDoc->get(IDocumentSettingAccess::ADD_EXT_LEADING);
     238         [ +  - ]:          9 :     rDop.fUsePrinterMetrics = !rWrt.pDoc->get(IDocumentSettingAccess::USE_VIRTUAL_DEVICE);
     239                 :            : 
     240                 :            :     // default TabStop schreiben
     241                 :            :     const SvxTabStopItem& rTabStop =
     242         [ +  - ]:          9 :         DefaultItemGet<SvxTabStopItem>(*rWrt.pDoc, RES_PARATR_TABSTOP);
     243         [ +  - ]:          9 :     rDop.dxaTab = (sal_uInt16)rTabStop[0].GetTabPos();
     244                 :            : 
     245                 :            : 
     246                 :            :     // Werte aus der DocStatistik (werden aufjedenfall fuer die
     247                 :            :     // DocStat-Felder benoetigt!)
     248                 :          9 :     rDop.fWCFtnEdn = true; // because they are included in StarWriter
     249                 :            : 
     250         [ +  - ]:          9 :     const SwDocStat& rDStat = rWrt.pDoc->GetDocStat();
     251                 :          9 :     rDop.cWords = rDStat.nWord;
     252                 :          9 :     rDop.cCh = rDStat.nChar;
     253                 :          9 :     rDop.cPg = static_cast< sal_Int16 >(rDStat.nPage);
     254                 :          9 :     rDop.cParas = rDStat.nPara;
     255                 :          9 :     rDop.cLines = rDStat.nPara;
     256                 :            : 
     257                 :          9 :     SwDocShell *pDocShell(rWrt.pDoc->GetDocShell());
     258                 :            :     OSL_ENSURE(pDocShell, "no SwDocShell");
     259                 :          9 :     uno::Reference<document::XDocumentProperties> xDocProps;
     260                 :          9 :     uno::Reference<beans::XPropertySet> xProps;
     261         [ +  - ]:          9 :     if (pDocShell) {
     262                 :            :         uno::Reference<lang::XComponent> xModelComp(pDocShell->GetModel(),
     263 [ +  - ][ +  - ]:          9 :            uno::UNO_QUERY);
     264                 :            :         xProps = uno::Reference<beans::XPropertySet>(xModelComp,
     265 [ +  - ][ +  - ]:          9 :            uno::UNO_QUERY);
     266                 :            :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
     267         [ +  - ]:          9 :             xModelComp, uno::UNO_QUERY_THROW);
     268 [ +  - ][ +  - ]:          9 :         xDocProps = xDPS->getDocumentProperties();
                 [ +  - ]
     269                 :            :         OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
     270                 :            : 
     271         [ +  - ]:          9 :         rDop.lKeyProtDoc = pDocShell->GetModifyPasswordHash();
     272                 :            :     }
     273                 :            : 
     274 [ +  - ][ +  - ]:          9 :     if ((rWrt.pSepx && rWrt.pSepx->DocumentIsProtected()) ||
         [ -  + ][ -  + ]
     275                 :            :         rDop.lKeyProtDoc != 0)
     276                 :            :     {
     277                 :          0 :         rDop.fProtEnabled =  1;
     278                 :            :     }
     279                 :            :     else
     280                 :            :     {
     281                 :          9 :         rDop.fProtEnabled = 0;
     282                 :            :     }
     283                 :            : 
     284         [ -  + ]:          9 :     if (!xDocProps.is()) {
     285                 :          0 :         rDop.dttmCreated = rDop.dttmRevised = rDop.dttmLastPrint = 0x45FBAC69;
     286                 :            :     } else {
     287 [ +  - ][ +  - ]:          9 :         ::util::DateTime uDT = xDocProps->getCreationDate();
     288                 :          9 :         Date aD(uDT.Day, uDT.Month, uDT.Year);
     289         [ +  - ]:          9 :         Time aT(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
     290 [ +  - ][ +  - ]:          9 :         rDop.dttmCreated = sw::ms::DateTime2DTTM(DateTime(aD,aT));
     291 [ +  - ][ +  - ]:          9 :         uDT = xDocProps->getModificationDate();
     292                 :          9 :         Date aD2(uDT.Day, uDT.Month, uDT.Year);
     293         [ +  - ]:          9 :         Time aT2(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
     294 [ +  - ][ +  - ]:          9 :         rDop.dttmRevised = sw::ms::DateTime2DTTM(DateTime(aD2,aT2));
     295 [ +  - ][ +  - ]:          9 :         uDT = xDocProps->getPrintDate();
     296                 :          9 :         Date aD3(uDT.Day, uDT.Month, uDT.Year);
     297         [ +  - ]:          9 :         Time aT3(uDT.Hours, uDT.Minutes, uDT.Seconds, uDT.HundredthSeconds);
     298 [ +  - ][ +  - ]:          9 :         rDop.dttmLastPrint = sw::ms::DateTime2DTTM(DateTime(aD3,aT3));
     299                 :            : 
     300                 :            :     }
     301                 :            : 
     302                 :            : //  auch damit werden die DocStat-Felder in Kopf-/Fusszeilen nicht korrekt
     303                 :            : //  berechnet.
     304                 :            : //  ( we do not have this fields! )
     305                 :            : 
     306                 :            :     // und noch fuer die Header und Footers
     307                 :          9 :     rDop.cWordsFtnEnd   = rDStat.nWord;
     308                 :          9 :     rDop.cChFtnEdn      = rDStat.nChar;
     309                 :          9 :     rDop.cPgFtnEdn      = (sal_Int16)rDStat.nPage;
     310                 :          9 :     rDop.cParasFtnEdn   = rDStat.nPara;
     311                 :          9 :     rDop.cLinesFtnEdn   = rDStat.nPara;
     312                 :            : 
     313         [ +  - ]:          9 :     rDop.fDontUseHTMLAutoSpacing = (rWrt.pDoc->get(IDocumentSettingAccess::PARA_SPACE_MAX) != 0);
     314                 :            : 
     315         [ +  - ]:          9 :     rDop.fExpShRtn = !rWrt.pDoc->get(IDocumentSettingAccess::DO_NOT_JUSTIFY_LINES_WITH_MANUAL_BREAK); // #i56856#
     316                 :            : 
     317         [ +  - ]:          9 :     rDop.Write( *rWrt.pTableStrm, *rWrt.pFib );
     318                 :          9 : }
     319                 :            : 
     320                 :         90 : const sal_Unicode *WW8DopTypography::GetJapanNotBeginLevel1()
     321                 :            : {
     322                 :            :     static const sal_Unicode aJapanNotBeginLevel1[nMaxFollowing] =
     323                 :            :     //Japanese Level 1
     324                 :            :     {
     325                 :            :         0x0021, 0x0025, 0x0029, 0x002c, 0x002e, 0x003a, 0x003b, 0x003f,
     326                 :            :         0x005d, 0x007d, 0x00a2, 0x00b0, 0x2019, 0x201d, 0x2030, 0x2032,
     327                 :            :         0x2033, 0x2103, 0x3001, 0x3002, 0x3005, 0x3009, 0x300b, 0x300d,
     328                 :            :         0x300f, 0x3011, 0x3015, 0x309b, 0x309c, 0x309d, 0x309e, 0x30fb,
     329                 :            :         0x30fd, 0x30fe, 0xff01, 0xff05, 0xff09, 0xff0c, 0xff0e, 0xff1a,
     330                 :            :         0xff1b, 0xff1f, 0xff3d, 0xff5d, 0xff61, 0xff63, 0xff64, 0xff65,
     331                 :            :         0xff9e, 0xff9f, 0xffe0
     332                 :            :     };
     333                 :         90 :     return &aJapanNotBeginLevel1[0];
     334                 :            : }
     335                 :            : 
     336                 :         90 : const sal_Unicode *WW8DopTypography::GetJapanNotEndLevel1()
     337                 :            : {
     338                 :            :     static const sal_Unicode aJapanNotEndLevel1[nMaxLeading] =
     339                 :            :     //Japanese Level 1
     340                 :            :     {
     341                 :            :         0x0024, 0x0028, 0x005b, 0x005c, 0x007b, 0x00a3, 0x00a5, 0x2018,
     342                 :            :         0x201c, 0x3008, 0x300a, 0x300c, 0x300e, 0x3010, 0x3014, 0xff04,
     343                 :            :         0xff08, 0xff3b, 0xff5b, 0xff62, 0xffe1, 0xffe5
     344                 :            :     };
     345                 :         90 :     return &aJapanNotEndLevel1[0];
     346                 :            : }
     347                 :            : 
     348                 :         12 : int lcl_CmpBeginEndChars( const rtl::OUString& rSWStr,
     349                 :            :     const sal_Unicode* pMSStr, int nMSStrByteLen )
     350                 :            : {
     351                 :         12 :     nMSStrByteLen /= sizeof( sal_Unicode );
     352         [ +  - ]:         12 :     if( nMSStrByteLen > rSWStr.getLength() )
     353                 :         12 :         nMSStrByteLen = rSWStr.getLength()+1;
     354                 :         12 :     nMSStrByteLen *= sizeof( sal_Unicode );
     355                 :            : 
     356                 :         12 :     return memcmp( rSWStr.getStr(), pMSStr, nMSStrByteLen );
     357                 :            : }
     358                 :            : 
     359                 :            : /*
     360                 :            : Converts the OOo Asian Typography into a best fit match for Microsoft
     361                 :            : Asian typography. This structure is actually dumped to disk within the
     362                 :            : Dop Writer. Assumption is that rTypo is cleared to 0 on entry
     363                 :            : */
     364                 :          9 : void WW8Export::ExportDopTypography(WW8DopTypography &rTypo)
     365                 :            : {
     366                 :            :     static const sal_Unicode aLangNotBegin[4][WW8DopTypography::nMaxFollowing]=
     367                 :            :     {
     368                 :            :         //Japanese Level 1
     369                 :            :         {
     370                 :            :             0x0021, 0x0025, 0x0029, 0x002c, 0x002e, 0x003a, 0x003b, 0x003f,
     371                 :            :             0x005d, 0x007d, 0x00a2, 0x00b0, 0x2019, 0x201d, 0x2030, 0x2032,
     372                 :            :             0x2033, 0x2103, 0x3001, 0x3002, 0x3005, 0x3009, 0x300b, 0x300d,
     373                 :            :             0x300f, 0x3011, 0x3015, 0x3041, 0x3043, 0x3045, 0x3047, 0x3049,
     374                 :            :             0x3063, 0x3083, 0x3085, 0x3087, 0x308e, 0x309b, 0x309c, 0x309d,
     375                 :            :             0x309e, 0x30a1, 0x30a3, 0x30a5, 0x30a7, 0x30a9, 0x30c3, 0x30e3,
     376                 :            :             0x30e5, 0x30e7, 0x30ee, 0x30f5, 0x30f6, 0x30fb, 0x30fc, 0x30fd,
     377                 :            :             0x30fe, 0xff01, 0xff05, 0xff09, 0xff0c, 0xff0e, 0xff1a, 0xff1b,
     378                 :            :             0xff1f, 0xff3d, 0xff5d, 0xff61, 0xff63, 0xff64, 0xff65, 0xff67,
     379                 :            :             0xff68, 0xff69, 0xff6a, 0xff6b, 0xff6c, 0xff6d, 0xff6e, 0xff6f,
     380                 :            :             0xff70, 0xff9e, 0xff9f, 0xffe0
     381                 :            :         },
     382                 :            :         //Simplified Chinese
     383                 :            :         {
     384                 :            :             0x0021, 0x0029, 0x002c, 0x002e, 0x003a, 0x003b, 0x003f, 0x005d,
     385                 :            :             0x007d, 0x00a8, 0x00b7, 0x02c7, 0x02c9, 0x2015, 0x2016, 0x2019,
     386                 :            :             0x201d, 0x2026, 0x2236, 0x3001, 0x3002, 0x3003, 0x3005, 0x3009,
     387                 :            :             0x300b, 0x300d, 0x300f, 0x3011, 0x3015, 0x3017, 0xff01, 0xff02,
     388                 :            :             0xff07, 0xff09, 0xff0c, 0xff0e, 0xff1a, 0xff1b, 0xff1f, 0xff3d,
     389                 :            :             0xff40, 0xff5c, 0xff5d, 0xff5e, 0xffe0
     390                 :            :         },
     391                 :            :         //Korean
     392                 :            :         {
     393                 :            :             0x0021, 0x0025, 0x0029, 0x002c, 0x002e, 0x003a, 0x003b, 0x003f,
     394                 :            :             0x005d, 0x007d, 0x00a2, 0x00b0, 0x2019, 0x201d, 0x2032, 0x2033,
     395                 :            :             0x2103, 0x3009, 0x300b, 0x300d, 0x300f, 0x3011, 0x3015, 0xff01,
     396                 :            :             0xff05, 0xff09, 0xff0c, 0xff0e, 0xff1a, 0xff1b, 0xff1f, 0xff3d,
     397                 :            :             0xff5d, 0xffe0
     398                 :            :         },
     399                 :            :         //Traditional Chinese
     400                 :            :         {
     401                 :            :             0x0021, 0x0029, 0x002c, 0x002e, 0x003a, 0x003b, 0x003f, 0x005d,
     402                 :            :             0x007d, 0x00a2, 0x00b7, 0x2013, 0x2014, 0x2019, 0x201d, 0x2022,
     403                 :            :             0x2025, 0x2026, 0x2027, 0x2032, 0x2574, 0x3001, 0x3002, 0x3009,
     404                 :            :             0x300b, 0x300d, 0x300f, 0x3011, 0x3015, 0x301e, 0xfe30, 0xfe31,
     405                 :            :             0xfe33, 0xfe34, 0xfe36, 0xfe38, 0xfe3a, 0xfe3c, 0xfe3e, 0xfe40,
     406                 :            :             0xfe42, 0xfe44, 0xfe4f, 0xfe50, 0xfe51, 0xfe52, 0xfe54, 0xfe55,
     407                 :            :             0xfe56, 0xfe57, 0xfe5a, 0xfe5c, 0xfe5e, 0xff01, 0xff09, 0xff0c,
     408                 :            :             0xff0e, 0xff1a, 0xff1b, 0xff1f, 0xff5c, 0xff5d, 0xff64
     409                 :            :         },
     410                 :            :     };
     411                 :            : 
     412                 :            :     static const sal_Unicode aLangNotEnd[4][WW8DopTypography::nMaxLeading] =
     413                 :            :     {
     414                 :            :         //Japanese Level 1
     415                 :            :         {
     416                 :            :             0x0024, 0x0028, 0x005b, 0x005c, 0x007b, 0x00a3, 0x00a5, 0x2018,
     417                 :            :             0x201c, 0x3008, 0x300a, 0x300c, 0x300e, 0x3010, 0x3014, 0xff04,
     418                 :            :             0xff08, 0xff3b, 0xff5b, 0xff62, 0xffe1, 0xffe5
     419                 :            :         },
     420                 :            :         //Simplified Chinese
     421                 :            :         {
     422                 :            :             0x0028, 0x005b, 0x007b, 0x00b7, 0x2018, 0x201c, 0x3008, 0x300a,
     423                 :            :             0x300c, 0x300e, 0x3010, 0x3014, 0x3016, 0xff08, 0xff0e, 0xff3b,
     424                 :            :             0xff5b, 0xffe1, 0xffe5
     425                 :            :         },
     426                 :            :         //Korean
     427                 :            :         {
     428                 :            :             0x0028, 0x005b, 0x005c, 0x007b, 0x00a3, 0x00a5, 0x2018, 0x201c,
     429                 :            :             0x3008, 0x300a, 0x300c, 0x300e, 0x3010, 0x3014, 0xff04, 0xff08,
     430                 :            :             0xff3b, 0xff5b, 0xffe6
     431                 :            :         },
     432                 :            :         //Traditional Chinese
     433                 :            :         {
     434                 :            :             0x0028, 0x005b, 0x007b, 0x00a3, 0x00a5, 0x2018, 0x201c, 0x2035,
     435                 :            :             0x3008, 0x300a, 0x300c, 0x300e, 0x3010, 0x3014, 0x301d, 0xfe35,
     436                 :            :             0xfe37, 0xfe39, 0xfe3b, 0xfe3d, 0xfe3f, 0xfe41, 0xfe43, 0xfe59,
     437                 :            :             0xfe5b, 0xfe5d, 0xff08, 0xff5b
     438                 :            :         },
     439                 :            :     };
     440                 :            : 
     441                 :          9 :     const i18n::ForbiddenCharacters *pForbidden = 0;
     442                 :          9 :     const i18n::ForbiddenCharacters *pUseMe = 0;
     443                 :          9 :     sal_uInt8 nUseReserved=0;
     444                 :          9 :     int nNoNeeded=0;
     445                 :            :     /*
     446                 :            :     Now we have some minor difficult issues, to wit...
     447                 :            :     a. MicroSoft Office can only store one set of begin and end characters in
     448                 :            :     a given document, not one per language.
     449                 :            :     b. StarOffice has only a concept of one set of begin and end characters for
     450                 :            :     a given language, i.e. not the two levels of kinsoku in japanese
     451                 :            : 
     452                 :            :     What is unknown as yet is if our default begin and end chars for
     453                 :            :     japanese, chinese tradition, chinese simplified and korean are different
     454                 :            :     in Word and Writer. I already suspect that they are different between
     455                 :            :     different version of word itself.
     456                 :            : 
     457                 :            :     So what have come up with is to simply see if any of the four languages
     458                 :            :     in OOo have been changed away from OUR defaults, and if one has then
     459                 :            :     export that. If more than one has in the future we may hack in something
     460                 :            :     which examines our document properties to see which language is used the
     461                 :            :     most and choose that, for now we choose the first and throw an ASSERT
     462                 :            :     */
     463                 :            : 
     464                 :            :     /*Our default Japanese Level is 2, this is a special MS hack to set this*/
     465                 :          9 :     rTypo.reserved2 = 1;
     466                 :            : 
     467         [ +  + ]:         45 :     for (rTypo.reserved1=8;rTypo.reserved1>0;rTypo.reserved1-=2)
     468                 :            :     {
     469         [ +  + ]:         36 :         if (0 != (pForbidden = pDoc->getForbiddenCharacters(rTypo.GetConvertedLang(),
     470                 :         72 :             false)))
     471                 :            :         {
     472                 :          3 :             int nIdx = (rTypo.reserved1-2)/2;
     473         [ +  - ]:          6 :             if( lcl_CmpBeginEndChars( pForbidden->endLine,
           [ +  -  +  - ]
     474                 :          3 :                     aLangNotEnd[ nIdx ], sizeof(aLangNotEnd[ nIdx ]) ) ||
     475                 :            :                 lcl_CmpBeginEndChars( pForbidden->beginLine,
     476                 :          3 :                     aLangNotBegin[ nIdx ], sizeof(aLangNotBegin[ nIdx ]) ) )
     477                 :            :             {
     478                 :            :                 //One exception for Japanese, if it matches a level 1 we
     479                 :            :                 //can use one extra flag for that, rather than use a custom
     480         [ +  - ]:          3 :                 if (rTypo.GetConvertedLang() == LANGUAGE_JAPANESE)
     481                 :            :                 {
     482         [ +  - ]:          6 :                     if (
           [ +  -  +  - ]
     483                 :            :                           !lcl_CmpBeginEndChars
     484                 :            :                             (
     485                 :            :                                 pForbidden->endLine,
     486                 :            :                                 rTypo.GetJapanNotEndLevel1(),
     487                 :            :                                 rTypo.nMaxLeading * sizeof(sal_Unicode)
     488                 :          3 :                             )
     489                 :            :                         &&
     490                 :            :                           !lcl_CmpBeginEndChars
     491                 :            :                             (
     492                 :            :                                 pForbidden->beginLine,
     493                 :            :                                 rTypo.GetJapanNotBeginLevel1(),
     494                 :            :                                 rTypo.nMaxFollowing * sizeof(sal_Unicode)
     495                 :          3 :                             )
     496                 :            :                         )
     497                 :            :                     {
     498                 :          3 :                         rTypo.reserved2 = 0;
     499                 :          3 :                         continue;
     500                 :            :                     }
     501                 :            :                 }
     502                 :            : 
     503         [ #  # ]:          0 :                 if (!pUseMe)
     504                 :            :                 {
     505                 :          0 :                     pUseMe = pForbidden;
     506                 :          0 :                     nUseReserved = rTypo.reserved1;
     507                 :          0 :                     rTypo.iLevelOfKinsoku = 2;
     508                 :            :                 }
     509                 :          0 :                 nNoNeeded++;
     510                 :            :             }
     511                 :            :         }
     512                 :            :     }
     513                 :            : 
     514                 :            :     OSL_ENSURE( nNoNeeded<=1, "Example of unexportable forbidden chars" );
     515                 :          9 :     rTypo.reserved1=nUseReserved;
     516         [ -  + ]:          9 :     if (rTypo.iLevelOfKinsoku)
     517                 :            :     {
     518                 :            :         rTypo.cchFollowingPunct = msword_cast<sal_Int16>
     519                 :          0 :             (pUseMe->beginLine.getLength());
     520         [ #  # ]:          0 :         if (rTypo.cchFollowingPunct > WW8DopTypography::nMaxFollowing - 1)
     521                 :          0 :             rTypo.cchFollowingPunct = WW8DopTypography::nMaxFollowing - 1;
     522                 :            : 
     523                 :            :         rTypo.cchLeadingPunct = msword_cast<sal_Int16>
     524                 :          0 :             (pUseMe->endLine.getLength());
     525         [ #  # ]:          0 :         if (rTypo.cchLeadingPunct > WW8DopTypography::nMaxLeading - 1)
     526                 :          0 :             rTypo.cchLeadingPunct = WW8DopTypography::nMaxLeading -1;
     527                 :            : 
     528                 :          0 :         memcpy(rTypo.rgxchFPunct,pUseMe->beginLine.getStr(),
     529                 :          0 :             (rTypo.cchFollowingPunct+1)*2);
     530                 :            : 
     531                 :          0 :         memcpy(rTypo.rgxchLPunct,pUseMe->endLine.getStr(),
     532                 :          0 :             (rTypo.cchLeadingPunct+1)*2);
     533                 :            :     }
     534                 :            : 
     535                 :          9 :     const IDocumentSettingAccess* pIDocumentSettingAccess = GetWriter().getIDocumentSettingAccess();
     536                 :            : 
     537                 :          9 :     rTypo.fKerningPunct = pIDocumentSettingAccess->get(IDocumentSettingAccess::KERN_ASIAN_PUNCTUATION);
     538                 :          9 :     rTypo.iJustification = pDoc->getCharacterCompressionType();
     539                 :          9 : }
     540                 :            : 
     541                 :            : // HasItem ist fuer die Zusammenfassung der Doppel-Attribute
     542                 :            : // Underline / WordLineMode und Box / Shadow.
     543                 :            : // Es kann nur etwas gefunden werden, wenn diese Methode innerhalb
     544                 :            : // der aufgerufenen Methoden WW8_SwAttrIter::OutAttr() und
     545                 :            : // WW8Export::OutputItemSet() benutzt wird.
     546                 :        135 : const SfxPoolItem* MSWordExportBase::HasItem( sal_uInt16 nWhich ) const
     547                 :            : {
     548                 :        135 :     const SfxPoolItem* pItem=0;
     549         [ +  - ]:        135 :     if (pISet)
     550                 :            :     {
     551                 :            :         // if write a EditEngine text, then the WhichIds are greater as
     552                 :            :         // ourer own Ids. So the Id have to translate from our into the
     553                 :            :         // EditEngine Range
     554         [ +  - ]:        135 :         nWhich = sw::hack::GetSetWhichFromSwDocWhich(*pISet, *pDoc, nWhich);
     555 [ +  - ][ +  - ]:        135 :         if (nWhich && SFX_ITEM_SET != pISet->GetItemState(nWhich, true, &pItem))
         [ +  - ][ +  - ]
     556                 :        135 :             pItem = 0;
     557                 :            :     }
     558         [ #  # ]:          0 :     else if( pChpIter )
     559         [ #  # ]:          0 :         pItem = pChpIter->HasTextItem( nWhich );
     560                 :            :     else
     561                 :            :     {
     562                 :            :         OSL_ENSURE( !this, "Wo ist mein ItemSet / pChpIter ?" );
     563                 :          0 :         pItem = 0;
     564                 :            :     }
     565                 :        135 :     return pItem;
     566                 :            : }
     567                 :            : 
     568                 :         78 : const SfxPoolItem& MSWordExportBase::GetItem(sal_uInt16 nWhich) const
     569                 :            : {
     570                 :            :     const SfxPoolItem* pItem;
     571         [ +  - ]:         78 :     if (pISet)
     572                 :            :     {
     573                 :            :         // if write a EditEngine text, then the WhichIds are greater as
     574                 :            :         // ourer own Ids. So the Id have to translate from our into the
     575                 :            :         // EditEngine Range
     576                 :         78 :         nWhich = sw::hack::GetSetWhichFromSwDocWhich(*pISet, *pDoc, nWhich);
     577                 :            :         OSL_ENSURE(nWhich != 0, "All broken, Impossible");
     578                 :         78 :         pItem = &pISet->Get(nWhich, true);
     579                 :            :     }
     580         [ #  # ]:          0 :     else if( pChpIter )
     581                 :          0 :         pItem = &pChpIter->GetItem( nWhich );
     582                 :            :     else
     583                 :            :     {
     584                 :            :         OSL_ENSURE( !this, "Wo ist mein ItemSet / pChpIter ?" );
     585                 :          0 :         pItem = 0;
     586                 :            :     }
     587                 :         78 :     return *pItem;
     588                 :            : }
     589                 :            : 
     590                 :            : //------------------------------------------------------------------------------
     591                 :            : 
     592                 :         72 : WW8_WrPlc1::WW8_WrPlc1( sal_uInt16 nStructSz )
     593                 :         72 :     : nStructSiz( nStructSz )
     594                 :            : {
     595                 :         72 :     nDataLen = 16 * nStructSz;
     596         [ +  - ]:         72 :     pData = new sal_uInt8[ nDataLen ];
     597                 :         72 : }
     598                 :            : 
     599                 :         72 : WW8_WrPlc1::~WW8_WrPlc1()
     600                 :            : {
     601         [ +  - ]:         72 :     delete[] pData;
     602                 :         72 : }
     603                 :            : 
     604                 :          0 : WW8_CP WW8_WrPlc1::Prev() const
     605                 :            : {
     606                 :          0 :     bool b = !aPos.empty();
     607                 :            :     OSL_ENSURE(b,"Prev called on empty list");
     608         [ #  # ]:          0 :     return b ? aPos.back() : 0;
     609                 :            : }
     610                 :            : 
     611                 :         18 : void WW8_WrPlc1::Append( WW8_CP nCp, const void* pNewData )
     612                 :            : {
     613                 :         18 :     sal_uLong nInsPos = aPos.size() * nStructSiz;
     614                 :         18 :     aPos.push_back( nCp );
     615         [ -  + ]:         18 :     if( nDataLen < nInsPos + nStructSiz )
     616                 :            :     {
     617                 :          0 :         sal_uInt8* pNew = new sal_uInt8[ 2 * nDataLen ];
     618                 :          0 :         memmove( pNew, pData, nDataLen );
     619         [ #  # ]:          0 :         delete[] pData;
     620                 :          0 :         pData = pNew;
     621                 :          0 :         nDataLen *= 2;
     622                 :            :     }
     623                 :         18 :     memcpy( pData + nInsPos, pNewData, nStructSiz );
     624                 :         18 : }
     625                 :            : 
     626                 :         72 : void WW8_WrPlc1::Finish( sal_uLong nLastCp, sal_uLong nSttCp )
     627                 :            : {
     628         [ +  + ]:         72 :     if( !aPos.empty() )
     629                 :            :     {
     630         [ +  - ]:         12 :         aPos.push_back( nLastCp );
     631         [ +  + ]:         12 :         if( nSttCp )
     632         [ +  + ]:         15 :             for( sal_uInt32 n = 0; n < aPos.size(); ++n )
     633                 :         12 :                 aPos[ n ] -= nSttCp;
     634                 :            :     }
     635                 :         72 : }
     636                 :            : 
     637                 :            : 
     638                 :         12 : void WW8_WrPlc1::Write( SvStream& rStrm )
     639                 :            : {
     640                 :            :     sal_uInt32 i;
     641         [ +  + ]:         42 :     for( i = 0; i < aPos.size(); ++i )
     642                 :         30 :         SwWW8Writer::WriteLong( rStrm, aPos[i] );
     643         [ +  - ]:         12 :     if( i )
     644                 :         12 :         rStrm.Write( pData, (i-1) * nStructSiz );
     645                 :         12 : }
     646                 :            : 
     647                 :            : //------------------------------------------------------------------------------
     648                 :            : //  Klasse WW8_WrPlcFld fuer Felder
     649                 :            : //------------------------------------------------------------------------------
     650                 :            : 
     651                 :            : 
     652                 :         63 : bool WW8_WrPlcFld::Write( WW8Export& rWrt )
     653                 :            : {
     654         [ +  + ]:         63 :     if( WW8_WrPlc1::Count() <= 1 )
     655                 :         60 :         return false;
     656                 :            : 
     657                 :            :     WW8_FC *pfc;
     658                 :            :     sal_Int32 *plc;
     659   [ -  -  -  -  :          3 :     switch (nTxtTyp)
             -  +  -  - ]
     660                 :            :     {
     661                 :            :         case TXT_MAINTEXT:
     662                 :          0 :             pfc = &rWrt.pFib->fcPlcffldMom;
     663                 :          0 :             plc = &rWrt.pFib->lcbPlcffldMom;
     664                 :          0 :             break;
     665                 :            :         case TXT_HDFT:
     666                 :          0 :             pfc = &rWrt.pFib->fcPlcffldHdr;
     667                 :          0 :             plc = &rWrt.pFib->lcbPlcffldHdr;
     668                 :          0 :             break;
     669                 :            : 
     670                 :            :         case TXT_FTN:
     671                 :          0 :             pfc = &rWrt.pFib->fcPlcffldFtn;
     672                 :          0 :             plc = &rWrt.pFib->lcbPlcffldFtn;
     673                 :          0 :             break;
     674                 :            : 
     675                 :            :         case TXT_EDN:
     676                 :          0 :             pfc = &rWrt.pFib->fcPlcffldEdn;
     677                 :          0 :             plc = &rWrt.pFib->lcbPlcffldEdn;
     678                 :          0 :             break;
     679                 :            : 
     680                 :            :         case TXT_ATN:
     681                 :          0 :             pfc = &rWrt.pFib->fcPlcffldAtn;
     682                 :          0 :             plc = &rWrt.pFib->lcbPlcffldAtn;
     683                 :          0 :             break;
     684                 :            : 
     685                 :            :         case TXT_TXTBOX:
     686                 :          3 :             pfc = &rWrt.pFib->fcPlcffldTxbx;
     687                 :          3 :             plc = &rWrt.pFib->lcbPlcffldTxbx;
     688                 :          3 :             break;
     689                 :            : 
     690                 :            :         case TXT_HFTXTBOX:
     691                 :          0 :             pfc = &rWrt.pFib->fcPlcffldHdrTxbx;
     692                 :          0 :             plc = &rWrt.pFib->lcbPlcffldHdrTxbx;
     693                 :          0 :             break;
     694                 :            : 
     695                 :            :         default:
     696                 :          0 :             pfc = plc = 0;
     697                 :          0 :             break;
     698                 :            :     }
     699                 :            : 
     700 [ +  - ][ +  - ]:          3 :     if( pfc && plc )
     701                 :            :     {
     702                 :          3 :         sal_uLong nFcStart = rWrt.pTableStrm->Tell();
     703                 :          3 :         WW8_WrPlc1::Write( *rWrt.pTableStrm );
     704                 :          3 :         *pfc = nFcStart;
     705                 :          3 :         *plc = rWrt.pTableStrm->Tell() - nFcStart;
     706                 :            :     }
     707                 :         63 :     return true;
     708                 :            : }
     709                 :            : 
     710                 :          9 : bool WW8_WrMagicTable::Write( WW8Export& rWrt )
     711                 :            : {
     712         [ -  + ]:          9 :     if( WW8_WrPlc1::Count() <= 1 )
     713                 :          0 :         return false;
     714                 :          9 :     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
     715                 :          9 :     WW8_WrPlc1::Write( *rWrt.pTableStrm );
     716                 :          9 :     rWrt.pFib->fcPlcfTch = nFcStart;
     717                 :          9 :     rWrt.pFib->lcbPlcfTch = rWrt.pTableStrm->Tell() - nFcStart;
     718                 :          9 :     return true;
     719                 :            : }
     720                 :            : 
     721                 :          9 : void WW8_WrMagicTable::Append( WW8_CP nCp, sal_uLong nData)
     722                 :            : {
     723                 :            :     SVBT32 nLittle;
     724                 :            :     /*
     725                 :            :     Tell the undocumented table hack that everything between here and the last
     726                 :            :     table position is nontable text, don't do it if the previous position is
     727                 :            :     the same as this one, as that would be a region of 0 length
     728                 :            :     */
     729 [ -  + ][ #  # ]:          9 :     if ((!Count()) || (Prev() != nCp))
         [ #  # ][ +  - ]
     730                 :            :     {
     731                 :          9 :         UInt32ToSVBT32(nData,nLittle);
     732         [ +  - ]:          9 :         WW8_WrPlc1::Append(nCp, nLittle);
     733                 :            :     }
     734                 :          9 : }
     735                 :            : 
     736                 :            : //--------------------------------------------------------------------------
     737                 :            : 
     738                 :        123 : void SwWW8Writer::FillCount( SvStream& rStrm, sal_uLong nCount )
     739                 :            : {
     740                 :            :     static const sal_uInt32 aNulls[16] =
     741                 :            :     {
     742                 :            :         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 // 64 Byte
     743                 :            :     };
     744                 :            : 
     745         [ +  + ]:        450 :     while (nCount > 64)
     746                 :            :     {
     747                 :        327 :         rStrm.Write( aNulls, 64 );          // in 64-Byte-Schritten
     748                 :        327 :         nCount -= 64;
     749                 :            :     }
     750                 :        123 :     rStrm.Write( aNulls, nCount );          // Rest ( 0 .. 64 Bytes ) schreiben
     751                 :        123 : }
     752                 :            : 
     753                 :         27 : sal_uLong SwWW8Writer::FillUntil( SvStream& rStrm, sal_uLong nEndPos )
     754                 :            : {
     755                 :         27 :     sal_uLong nCurPos = rStrm.Tell();
     756         [ +  + ]:         27 :     if( !nEndPos )                          // nEndPos == 0 -> next Page
     757                 :         18 :         nEndPos = (nCurPos + 0x1ff) & ~0x1ffUL;
     758                 :            : 
     759         [ +  + ]:         27 :     if( nEndPos > nCurPos )
     760                 :         18 :         SwWW8Writer::FillCount( rStrm, nEndPos - nCurPos );
     761                 :            : #if OSL_DEBUG_LEVEL > 0
     762                 :            :     else
     763                 :            :         OSL_ENSURE( nEndPos == nCurPos, "Falsches FillUntil()" );
     764                 :            : #endif
     765                 :         27 :     return rStrm.Tell();
     766                 :            : }
     767                 :            : 
     768                 :            : 
     769                 :            : //--------------------------------------------------------------------------
     770                 :            : 
     771                 :         18 : WW8_WrPlcPn::WW8_WrPlcPn( WW8Export& rWr, ePLCFT ePl, WW8_FC nStartFc )
     772                 :         18 :     : rWrt(rWr), nFkpStartPage(0), ePlc(ePl), nMark(0)
     773                 :            : {
     774 [ +  - ][ +  - ]:         18 :     WW8_WrFkp* pF = new WW8_WrFkp( ePlc, nStartFc, rWrt.bWrtWW8 );
     775         [ +  - ]:         18 :     aFkps.push_back( pF );
     776                 :         18 : }
     777                 :            : 
     778                 :         18 : WW8_WrPlcPn::~WW8_WrPlcPn()
     779                 :            : {
     780                 :         18 : }
     781                 :            : 
     782                 :          9 : sal_uInt8 *WW8_WrPlcPn::CopyLastSprms(sal_uInt8 &rLen)
     783                 :            : {
     784                 :          9 :     WW8_WrFkp& rF = aFkps.back();
     785                 :          9 :     return rF.CopyLastSprms(rLen, rWrt.bWrtWW8);
     786                 :            : }
     787                 :            : 
     788                 :        276 : void WW8_WrPlcPn::AppendFkpEntry(WW8_FC nEndFc,short nVarLen,const sal_uInt8* pSprms)
     789                 :            : {
     790         [ +  - ]:        276 :     WW8_WrFkp* pF = &aFkps.back();
     791                 :            : 
     792                 :            :     // big sprm? build the sprmPHugePapx
     793                 :        276 :     sal_uInt8* pNewSprms = (sal_uInt8*)pSprms;
     794                 :            :     sal_uInt8 aHugePapx[ 8 ];
     795 [ +  - ][ +  + ]:        276 :     if( rWrt.bWrtWW8 && PAP == ePlc && 488 < nVarLen )
                 [ -  + ]
     796                 :            :     {
     797                 :          0 :         sal_uInt8* p = aHugePapx;
     798                 :          0 :         *p++ = *pSprms++;           // set style Id
     799                 :          0 :         *p++ = *pSprms++;
     800                 :          0 :         nVarLen -= 2;
     801                 :            : 
     802                 :          0 :         long nDataPos = rWrt.pDataStrm->Tell();
     803         [ #  # ]:          0 :         SwWW8Writer::WriteShort( *rWrt.pDataStrm, nVarLen );
     804         [ #  # ]:          0 :         rWrt.pDataStrm->Write( pSprms, nVarLen );
     805                 :            : 
     806                 :          0 :         Set_UInt16( p, 0x6646 );    // set SprmCode
     807                 :          0 :         Set_UInt32( p, nDataPos );  // set startpos (FC) in the datastream
     808                 :          0 :         nVarLen = static_cast< short >(p - aHugePapx);
     809                 :          0 :         pSprms = pNewSprms = aHugePapx;
     810                 :            :     }
     811                 :            :     // if append at the same FC-EndPos and there are sprms, then get the old
     812                 :            :     // sprms and erase it; they will append now with the new sprms
     813 [ +  + ][ +  + ]:        276 :     else if( nVarLen && pF->IsEqualPos( nEndFc ))
                 [ +  + ]
     814         [ +  - ]:          3 :         pF->MergeToNew( nVarLen, pNewSprms );
     815                 :            :     // has the prev EndFC an empty sprm and the current is empty too, then
     816                 :            :     // expand only the old EndFc to the new EndFc
     817 [ +  + ][ +  + ]:        273 :     else if( !nVarLen && pF->IsEmptySprm() )
                 [ +  + ]
     818                 :            :     {
     819                 :         45 :         pF->SetNewEnd( nEndFc );
     820                 :        276 :         return ;
     821                 :            :     }
     822                 :            : 
     823                 :        231 :     bool bOk = pF->Append(nEndFc, nVarLen, pNewSprms);
     824         [ -  + ]:        231 :     if( !bOk )
     825                 :            :     {
     826                 :          0 :         pF->Combine();
     827 [ #  # ][ #  # ]:          0 :         pF = new WW8_WrFkp( ePlc, pF->GetEndFc(), rWrt.bWrtWW8 );// Anfang neuer Fkp
     828                 :            :                                                     // == Ende alter Fkp
     829         [ #  # ]:          0 :         aFkps.push_back( pF );
     830                 :          0 :         if( !pF->Append( nEndFc, nVarLen, pNewSprms ) )
     831                 :            :         {
     832                 :            :             OSL_ENSURE( !this, "Sprm liess sich nicht einfuegen" );
     833                 :            :         }
     834                 :            :     }
     835         [ +  + ]:        231 :     if( pNewSprms != pSprms )   //Merge to new has created a new block
     836         [ +  - ]:        231 :         delete[] pNewSprms;
     837                 :            : }
     838                 :            : 
     839                 :         18 : void WW8_WrPlcPn::WriteFkps()
     840                 :            : {
     841                 :         18 :     nFkpStartPage = (sal_uInt16) ( SwWW8Writer::FillUntil( rWrt.Strm() ) >> 9 );
     842                 :            : 
     843         [ +  + ]:         36 :     for( sal_uInt16 i = 0; i < aFkps.size(); i++ )
     844                 :         18 :         aFkps[ i ].Write( rWrt.Strm(), *rWrt.pGrf );
     845                 :            : 
     846         [ +  + ]:         18 :     if( CHP == ePlc )
     847                 :            :     {
     848                 :          9 :         rWrt.pFib->pnChpFirst = nFkpStartPage;
     849                 :          9 :         rWrt.pFib->cpnBteChp = aFkps.size();
     850                 :            :     }
     851                 :            :     else
     852                 :            :     {
     853                 :          9 :         rWrt.pFib->pnPapFirst = nFkpStartPage;
     854                 :          9 :         rWrt.pFib->cpnBtePap = aFkps.size();
     855                 :            :     }
     856                 :         18 : }
     857                 :            : 
     858                 :         18 : void WW8_WrPlcPn::WritePlc()
     859                 :            : {
     860                 :         18 :     sal_uLong nFcStart = rWrt.pTableStrm->Tell();
     861                 :            :     sal_uInt16 i;
     862                 :            : 
     863         [ +  + ]:         36 :     for( i = 0; i < aFkps.size(); i++ )
     864                 :            :         SwWW8Writer::WriteLong( *rWrt.pTableStrm,
     865                 :         18 :                                 aFkps[ i ].GetStartFc() );
     866                 :            : 
     867                 :            :     SwWW8Writer::WriteLong( *rWrt.pTableStrm,
     868                 :         18 :                                 aFkps[ i - 1 ].GetEndFc() );
     869                 :            : 
     870                 :            :     // fuer jedes FKP die Page ausgeben
     871         [ +  - ]:         18 :     if( rWrt.bWrtWW8)                   // fuer WW97 Long-Ausgabe
     872         [ +  + ]:         36 :         for ( i = 0; i < aFkps.size(); i++)
     873                 :         18 :             SwWW8Writer::WriteLong( *rWrt.pTableStrm, i + nFkpStartPage );
     874                 :            :     else                            // fuer WW95 Short-Ausgabe
     875         [ #  # ]:          0 :         for ( i = 0; i < aFkps.size(); i++)
     876                 :          0 :             SwWW8Writer::WriteShort( *rWrt.pTableStrm, i + nFkpStartPage );
     877                 :            : 
     878         [ +  + ]:         18 :     if( CHP == ePlc )
     879                 :            :     {
     880                 :          9 :         rWrt.pFib->fcPlcfbteChpx = nFcStart;
     881                 :          9 :         rWrt.pFib->lcbPlcfbteChpx = rWrt.pTableStrm->Tell() - nFcStart;
     882                 :            :     }
     883                 :            :     else
     884                 :            :     {
     885                 :          9 :         rWrt.pFib->fcPlcfbtePapx = nFcStart;
     886                 :          9 :         rWrt.pFib->lcbPlcfbtePapx = rWrt.pTableStrm->Tell() - nFcStart;
     887                 :            :     }
     888                 :         18 : }
     889                 :            : 
     890                 :            : //--------------------------------------------------------------------------
     891                 :            : 
     892                 :         18 : WW8_WrFkp::WW8_WrFkp(ePLCFT ePl, WW8_FC nStartFc, bool bWrtWW8)
     893                 :            :     : ePlc(ePl), nStartGrp(511), nOldStartGrp(511),
     894                 :            :     nItemSize( ( CHP == ePl ) ? 1 : ( bWrtWW8 ? 13 : 7 )),
     895 [ +  + ][ +  - ]:         18 :     nIMax(0), nOldVarLen(0), nMark(0), bCombined(false)
     896                 :            : {
     897                 :         18 :     pFkp = (sal_uInt8*)new sal_Int32[128];           // 512 Byte
     898                 :         18 :     pOfs = (sal_uInt8*)new sal_Int32[128];           // 512 Byte
     899                 :         18 :     memset( pFkp, 0, 4 * 128 );
     900                 :         18 :     memset( pOfs, 0, 4 * 128 );
     901                 :         18 :     ( (sal_Int32*)pFkp )[0] = nStartFc;         // 0. FC-Eintrag auf nStartFc
     902                 :         18 : }
     903                 :            : 
     904                 :         18 : WW8_WrFkp::~WW8_WrFkp()
     905                 :            : {
     906         [ +  - ]:         18 :     delete[] (sal_Int32 *)pFkp;
     907         [ -  + ]:         18 :     delete[] (sal_Int32 *)pOfs;
     908                 :         18 : }
     909                 :            : 
     910                 :        201 : sal_uInt8 WW8_WrFkp::SearchSameSprm( sal_uInt16 nVarLen, const sal_uInt8* pSprms )
     911                 :            : {
     912         [ +  + ]:        201 :     if( 3 < nVarLen )
     913                 :            :     {
     914                 :            :         // if the sprms contained picture-references then never equal!
     915         [ +  + ]:        795 :         for( sal_uInt8 n = static_cast< sal_uInt8 >(nVarLen - 1); 3 < n; --n )
     916 [ +  + ][ -  + ]:        708 :             if( pSprms[ n ] == GRF_MAGIC_3 &&
                 [ #  # ]
     917                 :          3 :                 pSprms[ n-1 ] == GRF_MAGIC_2 &&
     918                 :          0 :                 pSprms[ n-2 ] == GRF_MAGIC_1 )
     919                 :          0 :                     return 0;
     920                 :            :     }
     921                 :            : 
     922                 :            :     short i;
     923         [ +  + ]:       1392 :     for( i = 0; i < nIMax; i++ )
     924                 :            :     {
     925                 :       1251 :         sal_uInt8 nStart = pOfs[i * nItemSize];
     926         [ +  + ]:       1251 :         if( nStart )
     927                 :            :         {                               // Hat Sprms
     928                 :       1218 :             const sal_uInt8* p = pFkp + ( (sal_uInt16)nStart << 1 );
     929 [ +  + ][ +  + ]:       1218 :             if( ( CHP == ePlc
         [ +  + ][ +  - ]
                 [ +  + ]
     930                 :            :                     ? (*p++ == nVarLen)
     931                 :            :                     : (((sal_uInt16)*p++ << 1 ) == (( nVarLen+1) & 0xfffe)) )
     932                 :         60 :                 && !memcmp( p, pSprms, nVarLen ) )
     933                 :         60 :                     return nStart;                      // gefunden
     934                 :            :         }
     935                 :            :     }
     936                 :        201 :     return 0;           // nicht gefunden
     937                 :            : }
     938                 :            : 
     939                 :          9 : sal_uInt8 *WW8_WrFkp::CopyLastSprms(sal_uInt8 &rLen, bool bVer8)
     940                 :            : {
     941                 :          9 :     rLen=0;
     942                 :          9 :     sal_uInt8 *pStart=0,*pRet=0;
     943                 :            : 
     944         [ +  - ]:          9 :     if (!bCombined)
     945                 :          9 :         pStart = pOfs;
     946                 :            :     else
     947                 :          0 :         pStart = pFkp + ( nIMax + 1 ) * 4;
     948                 :            : 
     949                 :          9 :     sal_uInt8 nStart = *(pStart + (nIMax-1) * nItemSize);
     950                 :            : 
     951                 :          9 :     const sal_uInt8* p = pFkp + ( (sal_uInt16)nStart << 1 );
     952                 :            : 
     953 [ +  - ][ +  - ]:          9 :     if (!*p && bVer8)
     954                 :          9 :         p++;
     955                 :            : 
     956         [ +  - ]:          9 :     if (*p)
     957                 :            :     {
     958                 :          9 :         rLen = *p++;
     959         [ +  - ]:          9 :         if (PAP == ePlc)
     960                 :          9 :             rLen *= 2;
     961                 :          9 :         pRet = new sal_uInt8[rLen];
     962                 :          9 :         memcpy(pRet,p,rLen);
     963                 :            :     }
     964                 :          9 :     return pRet;
     965                 :            : }
     966                 :            : 
     967                 :        231 : bool WW8_WrFkp::Append( WW8_FC nEndFc, sal_uInt16 nVarLen, const sal_uInt8* pSprms )
     968                 :            : {
     969                 :            :     OSL_ENSURE( !nVarLen || pSprms, "Item-Pointer fehlt" );
     970                 :            :     OSL_ENSURE( nVarLen < ( ( ePlc == PAP ) ? 497U : 502U ), "Sprms zu lang !" );
     971                 :            : 
     972         [ -  + ]:        231 :     if( bCombined )
     973                 :            :     {
     974                 :            :         OSL_ENSURE( !this, "Fkp::Append: Fkp is already combined" );
     975                 :          0 :         return false;
     976                 :            :     }
     977                 :        231 :     sal_Int32 n = ((sal_Int32*)pFkp)[nIMax];        // letzter Eintrag
     978         [ +  + ]:        231 :     if( nEndFc <= n )
     979                 :            :     {
     980                 :            :         OSL_ENSURE( nEndFc >= n, "+Fkp: FC rueckwaerts" );
     981                 :            :         OSL_ENSURE( !nVarLen || !pSprms || nEndFc != n,
     982                 :            :                                     "+Fkp: selber FC mehrfach benutzt" );
     983                 :            :                         // selber FC ohne Sprm wird ohne zu mosern ignoriert.
     984                 :            : 
     985                 :          3 :         return true;    // ignorieren, keinen neuen Fkp anlegen
     986                 :            :     }
     987                 :            : 
     988         [ +  + ]:        228 :     sal_uInt8 nOldP = ( nVarLen ) ? SearchSameSprm( nVarLen, pSprms ) : 0;
     989                 :            :                                             // Kombinieren gleicher Eintraege
     990                 :        228 :     short nOffset=0, nPos = nStartGrp;
     991 [ +  + ][ +  + ]:        228 :     if (nVarLen && !nOldP)
     992                 :            :     {
     993                 :            :         nPos = PAP == ePlc
     994                 :            :                 ? ( 13 == nItemSize     // HACK: PAP und bWrtWW8 !!
     995                 :            :                      ? (nStartGrp & 0xFFFE ) - nVarLen - 1
     996                 :            :                      : (nStartGrp - (((nVarLen + 1) & 0xFFFE)+1)) & 0xFFFE )
     997 [ +  + ][ +  - ]:        141 :                 : ((nStartGrp - nVarLen - 1) & 0xFFFE);
     998         [ -  + ]:        141 :         if( nPos < 0 )
     999                 :          0 :             return false;           // Passt absolut nicht
    1000                 :        141 :         nOffset = nPos;             // Offset merken (kann auch ungerade sein!)
    1001                 :        141 :         nPos &= 0xFFFE;             // Pos fuer Sprms ( gerade Pos )
    1002                 :            :     }
    1003                 :            : 
    1004         [ -  + ]:        228 :     if( (sal_uInt16)nPos <= ( nIMax + 2U ) * 4U + ( nIMax + 1U ) * nItemSize )
    1005                 :            :                                             // Passt hinter CPs und Offsets ?
    1006                 :          0 :         return false;                       // Nein
    1007                 :            : 
    1008                 :        228 :     ((sal_Int32*)pFkp)[nIMax + 1] = nEndFc;     // FC eintragen
    1009                 :            : 
    1010                 :        228 :     nOldVarLen = (sal_uInt8)nVarLen;
    1011 [ +  + ][ +  + ]:        228 :     if( nVarLen && !nOldP )
    1012                 :            :     {               // echt eintragen
    1013                 :        141 :         nOldStartGrp = nStartGrp;
    1014                 :            : 
    1015                 :        141 :         nStartGrp = nPos;
    1016                 :        141 :         pOfs[nIMax * nItemSize] = (sal_uInt8)( nStartGrp >> 1 );
    1017                 :            :                                             // ( DatenAnfg >> 1 ) eintragen
    1018                 :            :         sal_uInt8 nCnt = static_cast< sal_uInt8 >(CHP == ePlc
    1019                 :            :                         ? ( nVarLen < 256 ) ? (sal_uInt8) nVarLen : 255
    1020 [ +  + ][ +  - ]:        141 :                         : ( ( nVarLen + 1 ) >> 1 ));
    1021                 :            : 
    1022                 :        141 :         pFkp[ nOffset ] = nCnt;                     // DatenLaenge eintragen
    1023                 :        141 :         memcpy( pFkp + nOffset + 1, pSprms, nVarLen );  // Sprms speichern
    1024                 :            :     }
    1025                 :            :     else
    1026                 :            :     {
    1027                 :            :         // nicht echt eintragen ( keine Sprms oder Wiederholung )
    1028                 :            :         // DatenAnfg 0 ( keine Daten ) oder Wiederholung
    1029                 :         87 :         pOfs[nIMax * nItemSize] = nOldP;
    1030                 :            :     }
    1031                 :        228 :     nIMax++;
    1032                 :        231 :     return true;
    1033                 :            : }
    1034                 :            : 
    1035                 :         18 : bool WW8_WrFkp::Combine()
    1036                 :            : {
    1037         [ -  + ]:         18 :     if( bCombined )
    1038                 :          0 :         return false;
    1039         [ +  - ]:         18 :     if( nIMax )
    1040                 :         18 :         memcpy( pFkp + ( nIMax + 1 ) * 4, pOfs, nIMax * nItemSize );
    1041         [ +  - ]:         18 :     delete[] pOfs;
    1042                 :         18 :     pOfs = 0;
    1043                 :         18 :     ((sal_uInt8*)pFkp)[511] = nIMax;
    1044                 :         18 :     bCombined = true;
    1045                 :            : 
    1046                 :            : #if defined OSL_BIGENDIAN         // Hier werden nur die FCs gedreht, die
    1047                 :            :     sal_uInt16 i;          // Sprms muessen an anderer Stelle gedreht
    1048                 :            :                                 // werden
    1049                 :            :     sal_uInt32* p;
    1050                 :            :     for( i = 0, p = (sal_uInt32*)pFkp; i <= nIMax; i++, p++ )
    1051                 :            :         *p = OSL_SWAPDWORD( *p );
    1052                 :            : #endif // ifdef OSL_BIGENDIAN
    1053                 :            : 
    1054                 :         18 :     return true;
    1055                 :            : }
    1056                 :            : 
    1057                 :         18 : void WW8_WrFkp::Write( SvStream& rStrm, SwWW8WrGrf& rGrf )
    1058                 :            : {
    1059                 :         18 :     Combine();                      // Falls noch nicht Combined
    1060                 :            : 
    1061                 :            :     sal_uInt8* p;               //  Suche Magic fuer nPicLocFc
    1062                 :         18 :     sal_uInt8* pEnd = pFkp + nStartGrp;
    1063         [ +  + ]:        948 :     for( p = pFkp + 511 - 4; p >= pEnd; p-- )
    1064                 :            :     {
    1065         [ +  + ]:        930 :         if( *p != GRF_MAGIC_1 )     // Suche nach Signatur 0x12 0x34 0x56 0xXX
    1066                 :        927 :             continue;
    1067         [ +  - ]:          3 :         if( *(p+1) != GRF_MAGIC_2 )
    1068                 :          3 :             continue;
    1069         [ #  # ]:          0 :         if( *(p+2) != GRF_MAGIC_3 )
    1070                 :          0 :             continue;
    1071                 :            : 
    1072                 :            :         SVBT32 nPos;                // Signatur gefunden
    1073         [ #  # ]:          0 :         UInt32ToSVBT32( rGrf.GetFPos(), nPos );   // FilePos der Grafik
    1074                 :        930 :         memcpy( p, nPos, 4 );       // Patche FilePos ueber Signatur
    1075                 :            :     }
    1076                 :         18 :     rStrm.Write( pFkp, 512 );
    1077                 :         18 : }
    1078                 :            : 
    1079                 :          3 : void WW8_WrFkp::MergeToNew( short& rVarLen, sal_uInt8 *& rpNewSprms )
    1080                 :            : {
    1081                 :          3 :     sal_uInt8 nStart = pOfs[ (nIMax-1) * nItemSize ];
    1082         [ +  - ]:          3 :     if( nStart )
    1083                 :            :     {   // Hat Sprms
    1084                 :          3 :         sal_uInt8* p = pFkp + ( (sal_uInt16)nStart << 1 );
    1085                 :            : 
    1086                 :            :         // old and new equal? Then copy only one into the new sprms
    1087 [ -  + ][ #  # ]:          3 :         if( nOldVarLen == rVarLen && !memcmp( p+1, rpNewSprms, nOldVarLen ))
    1088                 :            :         {
    1089                 :          0 :             sal_uInt8* pNew = new sal_uInt8[ nOldVarLen ];
    1090                 :          0 :             memcpy( pNew, p+1, nOldVarLen );
    1091                 :          0 :             rpNewSprms = pNew;
    1092                 :            :         }
    1093                 :            :         else
    1094                 :            :         {
    1095                 :          3 :             sal_uInt8* pNew = new sal_uInt8[ nOldVarLen + rVarLen ];
    1096                 :          3 :             memcpy( pNew, p+1, nOldVarLen );
    1097                 :          3 :             memcpy( pNew + nOldVarLen, rpNewSprms, rVarLen );
    1098                 :            : 
    1099                 :          3 :             rpNewSprms = pNew;
    1100                 :          3 :             rVarLen = rVarLen + nOldVarLen;
    1101                 :            :         }
    1102                 :          3 :         --nIMax;
    1103                 :            :         // if this sprms dont used from others, remove it
    1104                 :          3 :         bool bFnd = false;
    1105         [ +  - ]:         60 :         for (sal_uInt16 n = 0; n < nIMax; ++n)
    1106                 :            :         {
    1107         [ +  + ]:         60 :             if (nStart == pOfs[n * nItemSize])
    1108                 :            :             {
    1109                 :          3 :                 bFnd = true;
    1110                 :          3 :                 break;
    1111                 :            :             }
    1112                 :            :         }
    1113         [ -  + ]:          3 :         if (!bFnd)
    1114                 :            :         {
    1115                 :          0 :             nStartGrp = nOldStartGrp;
    1116                 :          0 :             memset( p, 0, nOldVarLen+1 );
    1117                 :            :         }
    1118                 :            :     }
    1119                 :          3 : }
    1120                 :            : 
    1121                 :            : #ifdef __WW8_NEEDS_COPY
    1122                 :            : 
    1123                 :         18 : WW8_FC WW8_WrFkp::GetStartFc() const
    1124                 :            : {
    1125                 :            : // wenn bCombined, dann ist das Array ab pFkp schon Bytemaessig auf LittleEndian
    1126                 :            : // umgedreht, d.h. zum Herausholen der Anfangs- und Endpositionen muss
    1127                 :            : // zurueckgedreht werden.
    1128         [ +  - ]:         18 :     if( bCombined )
    1129                 :         18 :         return SVBT32ToUInt32( pFkp );        // 0. Element
    1130                 :         18 :     return ((sal_Int32*)pFkp)[0];
    1131                 :            : }
    1132                 :            : 
    1133                 :         18 : WW8_FC WW8_WrFkp::GetEndFc() const
    1134                 :            : {
    1135         [ +  - ]:         18 :     if( bCombined )
    1136                 :         18 :         return SVBT32ToUInt32( &(pFkp[nIMax*4]) );    // nIMax-tes SVBT32-Element
    1137                 :         18 :     return ((sal_Int32*)pFkp)[nIMax];
    1138                 :            : }
    1139                 :            : 
    1140                 :            : #endif // defined __WW8_NEEDS_COPY
    1141                 :            : 
    1142                 :            : 
    1143                 :            : 
    1144                 :            : //--------------------------------------------------------------------------
    1145                 :            : // Methoden fuer Piece-Table-Verwaltung
    1146                 :            : //--------------------------------------------------------------------------
    1147                 :            : 
    1148                 :          9 : WW8_WrPct::WW8_WrPct(WW8_FC nfcMin, bool bSaveUniCode)
    1149                 :          9 :     : nOldFc(nfcMin), bIsUni(bSaveUniCode)
    1150                 :            : {
    1151         [ +  - ]:          9 :     AppendPc( nOldFc, bIsUni );
    1152                 :          9 : }
    1153                 :            : 
    1154                 :          9 : WW8_WrPct::~WW8_WrPct()
    1155                 :            : {
    1156                 :          9 : }
    1157                 :            : 
    1158                 :            : // Piece fuellen und neues Piece erzeugen
    1159                 :          9 : void WW8_WrPct::AppendPc(WW8_FC nStartFc, bool bIsUnicode)
    1160                 :            : {
    1161                 :          9 :     WW8_CP nStartCp = nStartFc - nOldFc;    // Textbeginn abziehen
    1162         [ +  - ]:          9 :     if ( !nStartCp )
    1163                 :            :     {
    1164         [ -  + ]:          9 :         if ( !aPcts.empty() )
    1165                 :            :         {
    1166                 :            :             OSL_ENSURE( 1 == aPcts.size(), "Leeres Piece !!");
    1167                 :          0 :             aPcts.pop_back( );
    1168                 :            :         }
    1169                 :            :     }
    1170                 :            : 
    1171                 :          9 :     nOldFc = nStartFc;                      // StartFc als alten merken
    1172                 :            : 
    1173         [ +  - ]:          9 :     if( bIsUni )
    1174                 :          9 :         nStartCp >>= 1;                 // Bei Unicode Anzahl der Zeichen / 2
    1175                 :            : 
    1176                 :            : 
    1177         [ -  + ]:          9 :     if ( !bIsUnicode )
    1178                 :            :     {
    1179                 :          0 :         nStartFc <<= 1;                 // Adresse * 2
    1180                 :          0 :         nStartFc |= 0x40000000;         // Vorletztes Bit setzen fuer !Unicode
    1181                 :            :     }
    1182                 :            : 
    1183         [ -  + ]:          9 :     if( !aPcts.empty() )
    1184                 :          0 :         nStartCp += aPcts.back().GetStartCp();
    1185                 :            : 
    1186                 :          9 :     WW8_WrPc* pPc = new WW8_WrPc( nStartFc, nStartCp );
    1187                 :          9 :     aPcts.push_back( pPc );
    1188                 :            : 
    1189                 :          9 :     bIsUni = bIsUnicode;
    1190                 :          9 : }
    1191                 :            : 
    1192                 :            : 
    1193                 :          9 : void WW8_WrPct::WritePc( WW8Export& rWrt )
    1194                 :            : {
    1195                 :            :     sal_uLong nPctStart;
    1196                 :            :     sal_uLong nOldPos, nEndPos;
    1197         [ +  - ]:          9 :     boost::ptr_vector<WW8_WrPc>::iterator aIter;
    1198                 :            : 
    1199                 :          9 :     nPctStart = rWrt.pTableStrm->Tell();                    // Beginn Piece-Table
    1200         [ +  - ]:          9 :     *rWrt.pTableStrm << ( char )0x02;                       // Statusbyte PCT
    1201                 :          9 :     nOldPos = nPctStart + 1;                                // Position merken
    1202         [ +  - ]:          9 :     SwWW8Writer::WriteLong( *rWrt.pTableStrm, 0 );          // Laenge folgt
    1203                 :            : 
    1204 [ +  - ][ +  - ]:         18 :     for( aIter = aPcts.begin(); aIter != aPcts.end(); ++aIter )     // Bereiche
         [ +  - ][ +  - ]
                 [ +  + ]
    1205                 :            :         SwWW8Writer::WriteLong( *rWrt.pTableStrm,
    1206 [ +  - ][ +  - ]:          9 :                                 aIter->GetStartCp() );
    1207                 :            : 
    1208                 :            : 
    1209                 :            :     // die letzte Pos noch errechnen
    1210                 :          9 :     sal_uLong nStartCp = rWrt.pFib->fcMac - nOldFc;
    1211         [ +  - ]:          9 :     if( bIsUni )
    1212                 :          9 :         nStartCp >>= 1;             // Bei Unicode Anzahl der Zeichen / 2
    1213         [ +  - ]:          9 :     nStartCp += aPcts.back().GetStartCp();
    1214         [ +  - ]:          9 :     SwWW8Writer::WriteLong( *rWrt.pTableStrm, nStartCp );
    1215                 :            : 
    1216                 :            :     // Pieceverweise
    1217 [ +  - ][ +  - ]:         18 :     for ( aIter = aPcts.begin(); aIter != aPcts.end(); ++aIter )
         [ +  - ][ +  - ]
                 [ +  + ]
    1218                 :            :     {
    1219 [ +  - ][ +  - ]:          9 :         SwWW8Writer::WriteShort( *rWrt.pTableStrm, aIter->GetStatus());
    1220 [ +  - ][ +  - ]:          9 :         SwWW8Writer::WriteLong( *rWrt.pTableStrm, aIter->GetStartFc());
    1221         [ +  - ]:          9 :         SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0);          // PRM=0
    1222                 :            :     }
    1223                 :            : 
    1224                 :            :     // Eintraege im FIB
    1225                 :          9 :     rWrt.pFib->fcClx = nPctStart;
    1226                 :          9 :     nEndPos = rWrt.pTableStrm->Tell();
    1227                 :          9 :     rWrt.pFib->lcbClx = nEndPos - nPctStart;
    1228                 :            : 
    1229                 :            :     // und noch die Laenge eintragen
    1230                 :            :     SwWW8Writer::WriteLong( *rWrt.pTableStrm, nOldPos,
    1231         [ +  - ]:          9 :                             nEndPos - nPctStart-5 );
    1232                 :            : 
    1233                 :          9 : }
    1234                 :            : 
    1235                 :        117 : void WW8_WrPct::SetParaBreak()
    1236                 :            : {
    1237                 :            :     OSL_ENSURE( !aPcts.empty(),"SetParaBreak : aPcts.empty()" );
    1238                 :        117 :     aPcts.back().SetStatus();
    1239                 :        117 : }
    1240                 :            : 
    1241                 :        162 : WW8_CP WW8_WrPct::Fc2Cp( sal_uLong nFc ) const
    1242                 :            : {
    1243                 :            :     OSL_ENSURE( nFc >= (sal_uLong)nOldFc, "FilePos liegt vorm letzten Piece" );
    1244                 :            :     OSL_ENSURE( ! aPcts.empty(), "Fc2Cp noch kein Piece vorhanden" );
    1245                 :            : 
    1246                 :        162 :     nFc -= nOldFc;
    1247         [ +  - ]:        162 :     if( bIsUni )
    1248                 :        162 :         nFc /= 2;
    1249                 :        162 :     return nFc + aPcts.back().GetStartCp();
    1250                 :            : }
    1251                 :            : 
    1252                 :            : //--------------------------------------------------------------------------
    1253                 :            : 
    1254                 :          9 : WW8_WrtBookmarks::WW8_WrtBookmarks()
    1255                 :            : {
    1256                 :          9 : }
    1257                 :            : 
    1258                 :          9 : WW8_WrtBookmarks::~WW8_WrtBookmarks()
    1259                 :            : {
    1260                 :          9 : }
    1261                 :            : 
    1262                 :         12 : void WW8_WrtBookmarks::Append( WW8_CP nStartCp, const String& rNm,  const ::sw::mark::IMark* )
    1263                 :            : {
    1264         [ +  - ]:         12 :     BkmIter bkIter = GetPos( rNm );
    1265 [ +  - ][ +  + ]:         12 :     if( bkIter == aBookmarks.end() )
    1266                 :            :     {
    1267                 :            :         // new bookmark -> insert with start==end
    1268 [ +  - ][ +  - ]:          6 :         aBookmarks.push_back( BookmarkInfo(nStartCp, nStartCp, false, rNm) );
                 [ +  - ]
    1269                 :            :     }
    1270                 :            :     else
    1271                 :            :     {
    1272                 :            :         // old bookmark -> this should be the end position
    1273                 :            :         OSL_ENSURE( bkIter->endPos == bkIter->startPos, "end position is valid" );
    1274                 :            : 
    1275                 :            :         //If this bookmark was around a field in writer, then we want to move
    1276                 :            :         //it to the field result in word. The end is therefore one cp
    1277                 :            :         //backwards from the 0x15 end mark that was inserted.
    1278         [ -  + ]:          6 :         if (bkIter->isField)
    1279                 :          0 :             --nStartCp;
    1280                 :          6 :         bkIter->endPos = nStartCp;
    1281                 :            :     }
    1282                 :         12 : }
    1283                 :            : 
    1284                 :            : 
    1285                 :          9 : void WW8_WrtBookmarks::Write( WW8Export& rWrt )
    1286                 :            : {
    1287         [ +  + ]:          9 :     if (!aBookmarks.empty())
    1288                 :            :     {
    1289                 :            :         //Make sure the bookmarks are sorted in order of start position.
    1290         [ +  - ]:          3 :         std::sort(aBookmarks.begin(), aBookmarks.end());
    1291                 :            : 
    1292                 :            :         // First write the Bookmark Name Stringtable
    1293         [ +  - ]:          3 :         std::vector<rtl::OUString> aNames;
    1294         [ +  - ]:          3 :         aNames.reserve(aBookmarks.size());
    1295 [ +  - ][ +  + ]:          9 :         for (BkmIter bIt = aBookmarks.begin(); bIt < aBookmarks.end(); ++bIt)
    1296 [ +  - ][ +  - ]:          6 :             aNames.push_back(bIt->name);
    1297         [ +  - ]:          3 :         rWrt.WriteAsStringTable(aNames, rWrt.pFib->fcSttbfbkmk, rWrt.pFib->lcbSttbfbkmk);
    1298                 :            : 
    1299                 :            :         // Second write the Bookmark start positions as pcf of longs
    1300 [ +  - ][ #  # ]:          3 :         SvStream& rStrm = rWrt.bWrtWW8 ? *rWrt.pTableStrm : rWrt.Strm();
    1301                 :          3 :         rWrt.pFib->fcPlcfbkf = rStrm.Tell();
    1302 [ +  - ][ +  + ]:          9 :         for (BkmIter bIt = aBookmarks.begin(); bIt < aBookmarks.end(); ++bIt)
    1303         [ +  - ]:          6 :             SwWW8Writer::WriteLong( rStrm, bIt->startPos );
    1304         [ +  - ]:          3 :         SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
    1305                 :            : 
    1306                 :            :         //Lastly, need to write out the end positions (sorted by end position). But
    1307                 :            :         //before that we need a lookup table (sorted by start position) to link
    1308                 :            :         //start and end positions.
    1309                 :            :         //   Start by sorting the end positions.
    1310         [ +  - ]:          3 :         std::vector<sal_uLong> aEndSortTab;
    1311         [ +  - ]:          3 :         aEndSortTab.reserve(aBookmarks.size());
    1312 [ +  - ][ +  + ]:          9 :         for (BkmIter bIt = aBookmarks.begin(); bIt < aBookmarks.end(); ++bIt)
    1313         [ +  - ]:          6 :             aEndSortTab.push_back(bIt->endPos);
    1314         [ +  - ]:          3 :         std::sort(aEndSortTab.begin(), aEndSortTab.end());
    1315                 :            : 
    1316                 :            :         //Now write out the lookups.
    1317                 :            :         //Note that in most cases, the positions in both vectors will be very close.
    1318         [ +  + ]:          9 :         for( sal_uLong i = 0; i < aBookmarks.size(); ++i )
    1319                 :            :         {
    1320                 :          6 :             sal_uLong nEndCP = aBookmarks[ i ].endPos;
    1321                 :          6 :             sal_uInt16 nPos = i;
    1322 [ -  + ][ +  - ]:          6 :             if( aEndSortTab[ nPos ] > nEndCP )
    1323                 :            :             {
    1324 [ #  # ][ #  # ]:          0 :                 while( aEndSortTab[ --nPos ] != nEndCP )
    1325                 :            :                     ;
    1326                 :            :             }
    1327 [ +  - ][ -  + ]:          6 :             else if( aEndSortTab[ nPos ] < nEndCP )
    1328 [ #  # ][ #  # ]:          0 :                 while( aEndSortTab[ ++nPos ] != nEndCP )
    1329                 :            :                     ;
    1330         [ +  - ]:          6 :             SwWW8Writer::WriteLong( rStrm, nPos );
    1331                 :            :         }
    1332                 :          3 :         rWrt.pFib->lcbPlcfbkf = rStrm.Tell() - rWrt.pFib->fcPlcfbkf;
    1333                 :            : 
    1334                 :            :         // Finally, the actual Bookmark end positions.
    1335                 :          3 :         rWrt.pFib->fcPlcfbkl = rStrm.Tell();
    1336         [ +  + ]:          9 :         for(sal_uLong i = 0; i < aEndSortTab.size(); ++i )
    1337 [ +  - ][ +  - ]:          6 :             SwWW8Writer::WriteLong( rStrm, aEndSortTab[ i ] );
    1338         [ +  - ]:          3 :         SwWW8Writer::WriteLong(rStrm, rWrt.pFib->ccpText + rWrt.pFib->ccpTxbx);
    1339                 :          3 :         rWrt.pFib->lcbPlcfbkl = rStrm.Tell() - rWrt.pFib->fcPlcfbkl;
    1340                 :            :     }
    1341                 :          9 : }
    1342                 :            : 
    1343                 :         12 : WW8_WrtBookmarks::BkmIter WW8_WrtBookmarks::GetPos( const String& rNm )
    1344                 :            : {
    1345 [ +  - ][ +  + ]:         18 :     for (BkmIter bIt = aBookmarks.begin(); bIt < aBookmarks.end(); ++bIt) {
    1346 [ +  - ][ +  + ]:         12 :         if (rNm == bIt->name)
    1347                 :          6 :             return bIt;
    1348                 :            :     }
    1349                 :         12 :     return aBookmarks.end();
    1350                 :            : }
    1351                 :            : 
    1352                 :          0 : void WW8_WrtBookmarks::MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo)
    1353                 :            : {
    1354 [ #  # ][ #  # ]:          0 :     for (BkmIter i = aBookmarks.begin(); i < aBookmarks.end(); ++i)
    1355                 :            :     {
    1356         [ #  # ]:          0 :         if (i->startPos == nFrom)
    1357                 :            :         {
    1358                 :          0 :             i->startPos = nTo;
    1359         [ #  # ]:          0 :             if (i->endPos == nFrom)
    1360                 :            :             {
    1361                 :          0 :                 i->isField = true;
    1362                 :          0 :                 i->endPos = nTo;
    1363                 :            :             }
    1364                 :            :         }
    1365                 :            :     }
    1366                 :          0 : }
    1367                 :            : 
    1368                 :        153 : void WW8Export::AppendBookmarks( const SwTxtNode& rNd,
    1369                 :            :     xub_StrLen nAktPos, xub_StrLen nLen )
    1370                 :            : {
    1371         [ +  - ]:        153 :     std::vector< const ::sw::mark::IMark* > aArr;
    1372                 :            :     sal_uInt16 nCntnt;
    1373                 :        153 :     xub_StrLen nAktEnd = nAktPos + nLen;
    1374 [ +  - ][ +  + ]:        153 :     if( GetWriter().GetBookmarks( rNd, nAktPos, nAktEnd, aArr ))
    1375                 :            :     {
    1376 [ +  - ][ +  - ]:          6 :         sal_uLong nNd = rNd.GetIndex(), nSttCP = Fc2Cp( Strm().Tell() );
    1377         [ +  + ]:         18 :         for( sal_uInt16 n = 0; n < aArr.size(); ++n )
    1378                 :            :         {
    1379         [ +  - ]:         12 :             const ::sw::mark::IMark& rBkmk = *(aArr[ n ]);
    1380 [ +  - ][ -  + ]:         12 :             if(dynamic_cast< const ::sw::mark::IFieldmark *>(&rBkmk))
    1381                 :          0 :                 continue;
    1382                 :            : 
    1383         [ +  - ]:         12 :             const SwPosition* pPos = &rBkmk.GetMarkPos();
    1384                 :         12 :             const SwPosition* pOPos = 0;
    1385 [ +  - ][ +  - ]:         12 :             if(rBkmk.IsExpanded())
    1386         [ +  - ]:         12 :                 pOPos = &rBkmk.GetOtherMarkPos();
    1387         [ +  - ]:         24 :             if( pOPos && pOPos->nNode == pPos->nNode &&
           [ +  -  -  + ]
                 [ -  + ]
    1388                 :         12 :                 pOPos->nContent < pPos->nContent )
    1389                 :            :             {
    1390                 :          0 :                 pPos = pOPos;
    1391         [ #  # ]:          0 :                 pOPos = &rBkmk.GetMarkPos();
    1392                 :            :             }
    1393                 :            : 
    1394 [ +  - ][ +  - ]:         12 :             if( !pOPos || ( nNd == pPos->nNode.GetIndex() &&
         [ +  + ][ +  - ]
                 [ +  + ]
    1395                 :         12 :                 ( nCntnt = pPos->nContent.GetIndex() ) >= nAktPos &&
    1396                 :            :                 nCntnt < nAktEnd ) )
    1397                 :            :             {
    1398                 :          6 :                 sal_uLong nCp = nSttCP + pPos->nContent.GetIndex() - nAktPos;
    1399 [ +  - ][ +  - ]:          6 :                 pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()), &rBkmk);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1400                 :            :             }
    1401 [ +  - ][ +  - ]:         12 :             if( pOPos && nNd == pOPos->nNode.GetIndex() &&
         [ +  - ][ +  + ]
                 [ +  + ]
    1402                 :         12 :                 ( nCntnt = pOPos->nContent.GetIndex() ) >= nAktPos &&
    1403                 :            :                 nCntnt < nAktEnd )
    1404                 :            :             {
    1405                 :          6 :                 sal_uLong nCp = nSttCP + pOPos->nContent.GetIndex() - nAktPos;
    1406 [ +  - ][ +  - ]:          6 :                 pBkmks->Append(nCp, BookmarkToWord(rBkmk.GetName()), &rBkmk);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1407                 :            :             }
    1408                 :            :         }
    1409                 :        153 :     }
    1410                 :        153 : }
    1411                 :            : 
    1412                 :          0 : void WW8Export::MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo)
    1413                 :            : {
    1414                 :          0 :     pBkmks->MoveFieldMarks(nFrom, nTo);
    1415                 :          0 : }
    1416                 :            : 
    1417                 :          0 : void WW8Export::AppendBookmark( const rtl::OUString& rName, bool bSkip )
    1418                 :            : {
    1419         [ #  # ]:          0 :     sal_uLong nSttCP = Fc2Cp( Strm().Tell() ) + ( bSkip? 1: 0 );
    1420         [ #  # ]:          0 :     pBkmks->Append( nSttCP, rName );
    1421                 :          0 : }
    1422                 :            : 
    1423                 :          0 : void MSWordExportBase::AppendWordBookmark( const String& rName )
    1424                 :            : {
    1425 [ #  # ][ #  # ]:          0 :     AppendBookmark( BookmarkToWord( rName ) );
    1426                 :          0 : }
    1427                 :            : 
    1428                 :            : 
    1429                 :            : //--------------------------------------------------------------------------
    1430                 :            : 
    1431                 :          0 : void WW8_WrtRedlineAuthor::Write( Writer& rWrt )
    1432                 :            : {
    1433                 :          0 :     WW8Export & rWW8Wrt = *(((SwWW8Writer&)rWrt).m_pExport);
    1434                 :            :     rWW8Wrt.WriteAsStringTable(maAuthors, rWW8Wrt.pFib->fcSttbfRMark,
    1435         [ #  # ]:          0 :         rWW8Wrt.pFib->lcbSttbfRMark, rWW8Wrt.bWrtWW8 ? 0 : 2);
    1436                 :          0 : }
    1437                 :            : 
    1438                 :          0 : sal_uInt16 WW8Export::AddRedlineAuthor( sal_uInt16 nId )
    1439                 :            : {
    1440         [ #  # ]:          0 :     if( !pRedlAuthors )
    1441                 :            :     {
    1442         [ #  # ]:          0 :         pRedlAuthors = new WW8_WrtRedlineAuthor;
    1443         [ #  # ]:          0 :         pRedlAuthors->AddName(rtl::OUString("Unknown"));
    1444                 :            :     }
    1445         [ #  # ]:          0 :     return pRedlAuthors->AddName( SW_MOD()->GetRedlineAuthor( nId ) );
    1446                 :            : }
    1447                 :            : 
    1448                 :            : //--------------------------------------------------------------------------
    1449                 :            : 
    1450                 :          6 : void WW8Export::WriteAsStringTable(const std::vector<rtl::OUString>& rStrings,
    1451                 :            :     sal_Int32& rfcSttbf, sal_Int32& rlcbSttbf, sal_uInt16 nExtraLen)
    1452                 :            : {
    1453                 :          6 :     sal_uInt16 n, nCount = static_cast< sal_uInt16 >(rStrings.size());
    1454         [ +  - ]:          6 :     if( nCount )
    1455                 :            :     {
    1456                 :            :         // we have some Redlines found in the document -> the
    1457                 :            :         // Author Name Stringtable
    1458         [ +  - ]:          6 :         SvStream& rStrm = bWrtWW8 ? *pTableStrm : Strm();
    1459                 :          6 :         rfcSttbf = rStrm.Tell();
    1460         [ +  - ]:          6 :         if( bWrtWW8 )
    1461                 :            :         {
    1462                 :          6 :             SwWW8Writer::WriteShort( rStrm, -1 );
    1463                 :          6 :             SwWW8Writer::WriteLong( rStrm, nCount );
    1464         [ +  + ]:         66 :             for( n = 0; n < nCount; ++n )
    1465                 :            :             {
    1466                 :         60 :                 const String& rNm = rStrings[n];
    1467         [ +  - ]:         60 :                 SwWW8Writer::WriteShort( rStrm, rNm.Len() );
    1468         [ +  - ]:         60 :                 SwWW8Writer::WriteString16(rStrm, rNm, false);
    1469         [ -  + ]:         60 :                 if( nExtraLen )
    1470         [ #  # ]:          0 :                     SwWW8Writer::FillCount(rStrm, nExtraLen);
    1471                 :         60 :             }
    1472                 :            :         }
    1473                 :            :         else
    1474                 :            :         {
    1475                 :          0 :             SwWW8Writer::WriteShort( rStrm, 0 );
    1476         [ #  # ]:          0 :             for( n = 0; n < nCount; ++n )
    1477                 :            :             {
    1478                 :          0 :                 const rtl::OUString &rString = rStrings[n];
    1479 [ #  # ][ #  # ]:          0 :                 const String aNm(rString.copy(0, std::min<sal_Int32>(rString.getLength(), 255)));
    1480         [ #  # ]:          0 :                 rStrm << (sal_uInt8)aNm.Len();
    1481                 :            :                 SwWW8Writer::WriteString8(rStrm, aNm, false,
    1482         [ #  # ]:          0 :                     RTL_TEXTENCODING_MS_1252);
    1483         [ #  # ]:          0 :                 if (nExtraLen)
    1484         [ #  # ]:          0 :                     SwWW8Writer::FillCount(rStrm, nExtraLen);
    1485         [ #  # ]:          0 :             }
    1486                 :            :         }
    1487                 :          6 :         rlcbSttbf = rStrm.Tell() - rfcSttbf;
    1488         [ -  + ]:          6 :         if( !bWrtWW8 )
    1489                 :          0 :             SwWW8Writer::WriteShort( rStrm, rfcSttbf, (sal_uInt16)rlcbSttbf );
    1490                 :            :     }
    1491                 :          6 : }
    1492                 :            : 
    1493                 :            : // WriteShort() traegt an FilePos nPos den Wert nVal ein und seekt auf die
    1494                 :            : // alte FilePos zurueck. Benutzt zum Nachtragen von Laengen.
    1495                 :          9 : void SwWW8Writer::WriteShort( SvStream& rStrm, sal_uLong nPos, sal_Int16 nVal )
    1496                 :            : {
    1497                 :          9 :     sal_uLong nOldPos = rStrm.Tell();       // Pos merken
    1498                 :          9 :     rStrm.Seek( nPos );
    1499                 :          9 :     SwWW8Writer::WriteShort( rStrm, nVal );
    1500                 :          9 :     rStrm.Seek( nOldPos );
    1501                 :          9 : }
    1502                 :            : 
    1503                 :         21 : void SwWW8Writer::WriteLong( SvStream& rStrm, sal_uLong nPos, sal_Int32 nVal )
    1504                 :            : {
    1505                 :         21 :     sal_uLong nOldPos = rStrm.Tell();       // Pos merken
    1506                 :         21 :     rStrm.Seek( nPos );
    1507                 :         21 :     SwWW8Writer::WriteLong( rStrm, nVal );
    1508                 :         21 :     rStrm.Seek( nOldPos );
    1509                 :         21 : }
    1510                 :            : 
    1511                 :       9867 : void SwWW8Writer::InsUInt16(ww::bytes &rO, sal_uInt16 n)
    1512                 :            : {
    1513                 :            :     SVBT16 nL;
    1514                 :       9867 :     ShortToSVBT16( n, nL );
    1515         [ +  - ]:       9867 :     rO.push_back(nL[0]);
    1516         [ +  - ]:       9867 :     rO.push_back(nL[1]);
    1517                 :       9867 : }
    1518                 :            : 
    1519                 :         30 : void SwWW8Writer::InsUInt32(ww::bytes &rO, sal_uInt32 n)
    1520                 :            : {
    1521                 :            :     SVBT32 nL;
    1522                 :         30 :     UInt32ToSVBT32( n, nL );
    1523         [ +  - ]:         30 :     rO.push_back(nL[0]);
    1524         [ +  - ]:         30 :     rO.push_back(nL[1]);
    1525         [ +  - ]:         30 :     rO.push_back(nL[2]);
    1526         [ +  - ]:         30 :     rO.push_back(nL[3]);
    1527                 :         30 : }
    1528                 :            : 
    1529                 :        486 : void SwWW8Writer::InsAsString16(ww::bytes &rO, const String& rStr)
    1530                 :            : {
    1531                 :        486 :     const sal_Unicode* pStr = rStr.GetBuffer();
    1532         [ +  + ]:       7041 :     for( xub_StrLen n = 0, nLen = rStr.Len(); n < nLen; ++n, ++pStr )
    1533                 :       6555 :         SwWW8Writer::InsUInt16( rO, *pStr );
    1534                 :        486 : }
    1535                 :            : 
    1536                 :          0 : void SwWW8Writer::InsAsString8(ww::bytes &rO, const String& rStr,
    1537                 :            :         rtl_TextEncoding eCodeSet)
    1538                 :            : {
    1539 [ #  # ][ #  # ]:          0 :     rtl::OString sTmp(rtl::OUStringToOString(rStr, eCodeSet));
    1540                 :          0 :     const sal_Char *pStart = sTmp.getStr();
    1541                 :          0 :     const sal_Char *pEnd = pStart + sTmp.getLength();
    1542         [ #  # ]:          0 :     rO.reserve(rO.size() + sTmp.getLength());
    1543                 :            : 
    1544 [ #  # ][ #  # ]:          0 :     std::copy(pStart, pEnd, std::inserter(rO, rO.end()));
    1545                 :          0 : }
    1546                 :            : 
    1547                 :        267 : void SwWW8Writer::WriteString16(SvStream& rStrm, const String& rStr,
    1548                 :            :     bool bAddZero)
    1549                 :            : {
    1550         [ +  - ]:        267 :     ww::bytes aBytes;
    1551         [ +  - ]:        267 :     SwWW8Writer::InsAsString16(aBytes, rStr);
    1552         [ +  + ]:        267 :     if (bAddZero)
    1553         [ +  - ]:        117 :         SwWW8Writer::InsUInt16(aBytes, 0);
    1554                 :            :     //vectors are guaranteed to have contiguous memory, so we can do
    1555                 :            :     //this while migrating away from WW8Bytes. Meyers Effective STL, item 16
    1556         [ +  + ]:        267 :     if (!aBytes.empty())
    1557 [ +  - ][ +  - ]:        267 :         rStrm.Write(&aBytes[0], aBytes.size());
    1558                 :        267 : }
    1559                 :            : 
    1560                 :          0 : void SwWW8Writer::WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero)
    1561                 :            : {
    1562         [ #  # ]:          0 :     ww::bytes aBytes;
    1563         [ #  # ]:          0 :     SwWW8Writer::InsUInt16(aBytes, rStr.Len());
    1564         [ #  # ]:          0 :     SwWW8Writer::InsAsString16(aBytes, rStr);
    1565         [ #  # ]:          0 :     if (bAddZero)
    1566         [ #  # ]:          0 :         SwWW8Writer::InsUInt16(aBytes, 0);
    1567 [ #  # ][ #  # ]:          0 :     rStrm.Write(&aBytes[0], aBytes.size());
    1568                 :          0 : }
    1569                 :            : 
    1570                 :            : 
    1571                 :          0 : void SwWW8Writer::WriteString8(SvStream& rStrm, const String& rStr,
    1572                 :            :     bool bAddZero, rtl_TextEncoding eCodeSet)
    1573                 :            : {
    1574         [ #  # ]:          0 :     ww::bytes aBytes;
    1575         [ #  # ]:          0 :     SwWW8Writer::InsAsString8(aBytes, rStr, eCodeSet);
    1576         [ #  # ]:          0 :     if (bAddZero)
    1577         [ #  # ]:          0 :         aBytes.push_back(0);
    1578                 :            :     //vectors are guaranteed to have contiguous memory, so we can do
    1579                 :            :     ////this while migrating away from WW8Bytes. Meyers Effective STL, item 16
    1580         [ #  # ]:          0 :     if (!aBytes.empty())
    1581 [ #  # ][ #  # ]:          0 :         rStrm.Write(&aBytes[0], aBytes.size());
    1582                 :          0 : }
    1583                 :            : 
    1584                 :         36 : void WW8Export::WriteStringAsPara( const String& rTxt, sal_uInt16 nStyleId )
    1585                 :            : {
    1586         [ -  + ]:         36 :     if( rTxt.Len() )
    1587         [ #  # ]:          0 :         OutSwString( rTxt, 0, rTxt.Len(), IsUnicode(), RTL_TEXTENCODING_MS_1252 );
    1588 [ +  - ][ +  - ]:         36 :     WriteCR();              // CR danach
                 [ +  - ]
    1589                 :            : 
    1590         [ +  - ]:         36 :     ww::bytes aArr;
    1591         [ +  - ]:         36 :     SwWW8Writer::InsUInt16( aArr, nStyleId );
    1592         [ -  + ]:         36 :     if( bOutTable )
    1593                 :            :     {                                               // Tab-Attr
    1594                 :            :         // sprmPFInTable
    1595         [ #  # ]:          0 :         if( bWrtWW8 )
    1596         [ #  # ]:          0 :             SwWW8Writer::InsUInt16( aArr, NS_sprm::LN_PFInTable );
    1597                 :            :         else
    1598         [ #  # ]:          0 :             aArr.push_back( 24 );
    1599         [ #  # ]:          0 :         aArr.push_back( 1 );
    1600                 :            :     }
    1601                 :            : 
    1602         [ +  - ]:         36 :     sal_uLong nPos = Strm().Tell();
    1603 [ +  - ][ +  - ]:         36 :     pPapPlc->AppendFkpEntry( nPos, aArr.size(), aArr.data() );
    1604         [ +  - ]:         36 :     pChpPlc->AppendFkpEntry( nPos );
    1605                 :         36 : }
    1606                 :            : 
    1607                 :          9 : void MSWordExportBase::WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp )
    1608                 :            : {
    1609                 :          9 :     sal_uInt8 nOldTyp = nTxtTyp;
    1610                 :          9 :     nTxtTyp = nTTyp;
    1611                 :          9 :     SwPaM* pOldPam = pCurPam;       //!! Einfaches Umsetzen des PaM ohne
    1612                 :          9 :     SwPaM* pOldEnd = pOrigPam;          // Wiederherstellen muesste es auch tun
    1613                 :          9 :     bool bOldPageDescs = bOutPageDescs;
    1614                 :          9 :     bOutPageDescs = false;
    1615                 :            :                                     // bOutKF wird in WriteKF1 gemerkt / gesetzt
    1616                 :          9 :     pCurPam = Writer::NewSwPaM( *pDoc, nStart, nEnd );
    1617                 :            : 
    1618                 :            :     // Tabelle in Sonderbereichen erkennen
    1619         [ -  + ]:          9 :     if ( ( nStart != pCurPam->GetMark()->nNode.GetIndex() ) &&
           [ -  +  #  # ]
    1620                 :          0 :          pDoc->GetNodes()[ nStart ]->IsTableNode() )
    1621                 :            :     {
    1622                 :          0 :         pCurPam->GetMark()->nNode = nStart;
    1623                 :            :     }
    1624                 :            : 
    1625                 :          9 :     pOrigPam = pCurPam;
    1626                 :          9 :     pCurPam->Exchange();
    1627                 :            : 
    1628                 :          9 :     WriteText();
    1629                 :            : 
    1630                 :          9 :     bOutPageDescs = bOldPageDescs;
    1631         [ +  - ]:          9 :     delete pCurPam;                    // Pam wieder loeschen
    1632                 :          9 :     pCurPam = pOldPam;
    1633                 :          9 :     pOrigPam = pOldEnd;
    1634                 :          9 :     nTxtTyp = nOldTyp;
    1635                 :          9 : }
    1636                 :            : 
    1637                 :         60 : void WW8Export::OutSwString(const String& rStr, xub_StrLen nStt,
    1638                 :            :     xub_StrLen nLen, bool bUnicode, rtl_TextEncoding eChrSet)
    1639                 :            : 
    1640                 :            : {
    1641                 :            : #if OSL_DEBUG_LEVEL > 1
    1642                 :            :     ::std::clog << "<OutSwString>" << ::std::endl;
    1643                 :            : #endif
    1644                 :            : 
    1645         [ +  - ]:         60 :     if( nLen )
    1646                 :            :     {
    1647         [ -  + ]:         60 :         if ( bUnicode != pPiece->IsUnicode() )
    1648                 :          0 :             pPiece->AppendPc ( Strm().Tell(), bUnicode );
    1649                 :            : 
    1650 [ +  - ][ -  + ]:         60 :         if( nStt || nLen != rStr.Len() )
                 [ -  + ]
    1651                 :            :         {
    1652         [ #  # ]:          0 :             String sOut( rStr.Copy( nStt, nLen ) );
    1653                 :            : 
    1654                 :            : #if OSL_DEBUG_LEVEL > 1
    1655                 :            :             ::std::clog << ::rtl::OUStringToOString(sOut, RTL_TEXTENCODING_ASCII_US).getStr() << ::std::endl;
    1656                 :            : #endif
    1657                 :            : 
    1658         [ #  # ]:          0 :             if (bUnicode)
    1659 [ #  # ][ #  # ]:          0 :                 SwWW8Writer::WriteString16(Strm(), sOut, false);
    1660                 :            :             else
    1661 [ #  # ][ #  # ]:          0 :                 SwWW8Writer::WriteString8(Strm(), sOut, false, eChrSet);
                 [ #  # ]
    1662                 :            :         }
    1663                 :            :         else
    1664                 :            :         {
    1665                 :            : #if OSL_DEBUG_LEVEL > 1
    1666                 :            :             ::std::clog << ::rtl::OUStringToOString(rStr, RTL_TEXTENCODING_ASCII_US).getStr() << ::std::endl;
    1667                 :            : #endif
    1668                 :            : 
    1669         [ +  - ]:         60 :             if (bUnicode)
    1670                 :         60 :                 SwWW8Writer::WriteString16(Strm(), rStr, false);
    1671                 :            :             else
    1672                 :          0 :                 SwWW8Writer::WriteString8(Strm(), rStr, false, eChrSet);
    1673                 :            :         }
    1674                 :            :     }
    1675                 :            : 
    1676                 :            : #if OSL_DEBUG_LEVEL > 1
    1677                 :            :     ::std::clog << "</OutSwString>" << ::std::endl;
    1678                 :            : #endif
    1679                 :         60 : }
    1680                 :            : 
    1681                 :        117 : void WW8Export::WriteCR(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
    1682                 :            : {
    1683 [ -  + ][ #  # ]:        117 :     if (pTableTextNodeInfoInner.get() != NULL && pTableTextNodeInfoInner->getDepth() == 1 && pTableTextNodeInfoInner->isEndOfCell())
         [ #  # ][ -  + ]
    1684                 :          0 :         WriteChar('\007');
    1685                 :            :     else
    1686                 :        117 :         WriteChar( '\015' );
    1687                 :            : 
    1688                 :        117 :     pPiece->SetParaBreak();
    1689                 :        117 : }
    1690                 :            : 
    1691                 :        141 : void WW8Export::WriteChar( sal_Unicode c )
    1692                 :            : {
    1693         [ +  - ]:        141 :     if( pPiece->IsUnicode() )
    1694                 :        141 :         Strm() << c;
    1695                 :            :     else
    1696                 :          0 :         Strm() << (sal_uInt8)c;
    1697                 :        141 : }
    1698                 :            : 
    1699                 :          0 : void MSWordExportBase::SaveData( sal_uLong nStt, sal_uLong nEnd )
    1700                 :            : {
    1701                 :            :     MSWordSaveData aData;
    1702                 :            : 
    1703                 :            :     // WW8Export only stuff - zeroed here not to issue warnings
    1704                 :          0 :     aData.pOOld = NULL;
    1705                 :            : 
    1706                 :            :     // Common stuff
    1707                 :          0 :     aData.pOldPam = pCurPam;
    1708                 :          0 :     aData.pOldEnd = pOrigPam;
    1709                 :          0 :     aData.pOldFlyFmt = mpParentFrame;
    1710                 :          0 :     aData.pOldPageDesc = pAktPageDesc;
    1711                 :            : 
    1712                 :          0 :     aData.pOldFlyOffset = pFlyOffset;
    1713                 :          0 :     aData.eOldAnchorType = eNewAnchorType;
    1714                 :            : 
    1715                 :          0 :     aData.bOldOutTable = bOutTable;
    1716                 :          0 :     aData.bOldFlyFrmAttrs = bOutFlyFrmAttrs;
    1717                 :          0 :     aData.bOldStartTOX = bStartTOX;
    1718                 :          0 :     aData.bOldInWriteTOX = bInWriteTOX;
    1719                 :            : 
    1720         [ #  # ]:          0 :     pCurPam = Writer::NewSwPaM( *pDoc, nStt, nEnd );
    1721                 :            : 
    1722                 :            :     // Recognize tables in special cases
    1723   [ #  #  #  # ]:          0 :     if ( nStt != pCurPam->GetMark()->nNode.GetIndex() &&
                 [ #  # ]
    1724 [ #  # ][ #  # ]:          0 :          pDoc->GetNodes()[ nStt ]->IsTableNode() )
    1725                 :            :     {
    1726         [ #  # ]:          0 :         pCurPam->GetMark()->nNode = nStt;
    1727                 :            :     }
    1728                 :            : 
    1729                 :          0 :     pOrigPam = pCurPam;
    1730                 :          0 :     pCurPam->Exchange();
    1731                 :            : 
    1732                 :          0 :     bOutTable = false;
    1733                 :            :     // Caution: bIsInTable should not be set here
    1734                 :          0 :     bOutFlyFrmAttrs = false;
    1735                 :          0 :     bStartTOX = false;
    1736                 :          0 :     bInWriteTOX = false;
    1737                 :            : 
    1738         [ #  # ]:          0 :     maSaveData.push( aData );
    1739                 :          0 : }
    1740                 :            : 
    1741                 :          0 : void MSWordExportBase::RestoreData()
    1742                 :            : {
    1743                 :          0 :     MSWordSaveData &rData = maSaveData.top();
    1744                 :            : 
    1745         [ #  # ]:          0 :     delete pCurPam;
    1746                 :          0 :     pCurPam = rData.pOldPam;
    1747                 :          0 :     pOrigPam = rData.pOldEnd;
    1748                 :            : 
    1749                 :          0 :     bOutTable = rData.bOldOutTable;
    1750                 :          0 :     bOutFlyFrmAttrs = rData.bOldFlyFrmAttrs;
    1751                 :          0 :     bStartTOX = rData.bOldStartTOX;
    1752                 :          0 :     bInWriteTOX = rData.bOldInWriteTOX;
    1753                 :            : 
    1754                 :          0 :     mpParentFrame = rData.pOldFlyFmt;
    1755                 :          0 :     pAktPageDesc = rData.pOldPageDesc;
    1756                 :            : 
    1757                 :          0 :     eNewAnchorType = rData.eOldAnchorType;
    1758                 :          0 :     pFlyOffset = rData.pOldFlyOffset;
    1759                 :            : 
    1760                 :          0 :     maSaveData.pop();
    1761                 :          0 : }
    1762                 :            : 
    1763                 :          0 : void WW8Export::SaveData( sal_uLong nStt, sal_uLong nEnd )
    1764                 :            : {
    1765                 :          0 :     MSWordExportBase::SaveData( nStt, nEnd );
    1766                 :            : 
    1767                 :          0 :     MSWordSaveData &rData = maSaveData.top();
    1768                 :            : 
    1769         [ #  # ]:          0 :     if ( !pO->empty() )
    1770                 :            :     {
    1771                 :          0 :         rData.pOOld = pO;
    1772         [ #  # ]:          0 :         pO = new ww::bytes();
    1773                 :            :     }
    1774                 :            :     else
    1775                 :          0 :         rData.pOOld = 0; // reuse pO
    1776                 :            : 
    1777                 :          0 :     rData.bOldWriteAll = GetWriter().bWriteAll;
    1778                 :          0 :     GetWriter().bWriteAll = true;
    1779                 :          0 : }
    1780                 :            : 
    1781                 :          0 : void WW8Export::RestoreData()
    1782                 :            : {
    1783                 :          0 :     MSWordSaveData &rData = maSaveData.top();
    1784                 :            : 
    1785                 :          0 :     GetWriter().bWriteAll = rData.bOldWriteAll;
    1786                 :            : 
    1787                 :            :     OSL_ENSURE( pO->empty(), "pO is not empty in WW8Export::RestoreData()" );
    1788         [ #  # ]:          0 :     if ( rData.pOOld )
    1789                 :            :     {
    1790         [ #  # ]:          0 :         delete pO;
    1791                 :          0 :         pO = rData.pOOld;
    1792                 :            :     }
    1793                 :            : 
    1794                 :          0 :     MSWordExportBase::RestoreData();
    1795                 :          0 : }
    1796                 :            : 
    1797                 :          0 : void WW8AttributeOutput::TableInfoCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1798                 :            : {
    1799                 :          0 :     sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
    1800                 :            : 
    1801         [ #  # ]:          0 :     if ( nDepth > 0 )
    1802                 :            :     {
    1803                 :            :         /* Cell */
    1804                 :          0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PFInTable );
    1805         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1806                 :          0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_PTableDepth );
    1807                 :          0 :         m_rWW8Export.InsUInt32( nDepth );
    1808                 :            : 
    1809 [ #  # ][ #  # ]:          0 :         if ( nDepth > 1 && pTableTextNodeInfoInner->isEndOfCell() )
                 [ #  # ]
    1810                 :            :         {
    1811                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PCell );
    1812         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1813                 :            :         }
    1814                 :            :     }
    1815                 :          0 : }
    1816                 :            : 
    1817                 :          0 : void WW8AttributeOutput::TableInfoRow( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1818                 :            : {
    1819                 :          0 :     sal_uInt32 nDepth = pTableTextNodeInfoInner->getDepth();
    1820                 :            : 
    1821         [ #  # ]:          0 :     if ( nDepth > 0 )
    1822                 :            :     {
    1823                 :            :         /* Row */
    1824         [ #  # ]:          0 :         if ( pTableTextNodeInfoInner->isEndOfLine() )
    1825                 :            :         {
    1826                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PFInTable );
    1827         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1828                 :            : 
    1829         [ #  # ]:          0 :             if ( nDepth == 1 )
    1830                 :            :             {
    1831                 :          0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_PFTtp );
    1832         [ #  # ]:          0 :                 m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1833                 :            :             }
    1834                 :            : 
    1835                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_PTableDepth );
    1836                 :          0 :             m_rWW8Export.InsUInt32( nDepth );
    1837                 :            : 
    1838         [ #  # ]:          0 :             if ( nDepth > 1 )
    1839                 :            :             {
    1840                 :          0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_PCell );
    1841         [ #  # ]:          0 :                 m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1842                 :          0 :                 m_rWW8Export.InsUInt16( NS_sprm::LN_PRow );
    1843         [ #  # ]:          0 :                 m_rWW8Export.pO->push_back( (sal_uInt8)0x1 );
    1844                 :            :             }
    1845                 :            : 
    1846         [ #  # ]:          0 :             TableDefinition( pTableTextNodeInfoInner );
    1847         [ #  # ]:          0 :             TableHeight( pTableTextNodeInfoInner );
    1848         [ #  # ]:          0 :             TableBackgrounds( pTableTextNodeInfoInner );
    1849         [ #  # ]:          0 :             TableDefaultBorders( pTableTextNodeInfoInner );
    1850         [ #  # ]:          0 :             TableCanSplit( pTableTextNodeInfoInner );
    1851         [ #  # ]:          0 :             TableBidi( pTableTextNodeInfoInner );
    1852         [ #  # ]:          0 :             TableVerticalCell( pTableTextNodeInfoInner );
    1853         [ #  # ]:          0 :             TableOrientation( pTableTextNodeInfoInner );
    1854         [ #  # ]:          0 :             TableSpacing( pTableTextNodeInfoInner );
    1855                 :            :         }
    1856                 :            :     }
    1857                 :          0 : }
    1858                 :            : 
    1859                 :          0 : static sal_uInt16 lcl_TCFlags(const SwTableBox * pBox, long nRowSpan)
    1860                 :            : {
    1861                 :          0 :     sal_uInt16 nFlags = 0;
    1862                 :            : 
    1863         [ #  # ]:          0 :     if (nRowSpan > 1)
    1864                 :          0 :         nFlags |= (3 << 5);
    1865         [ #  # ]:          0 :     else if (nRowSpan < 0)
    1866                 :          0 :         nFlags |= (1 << 5);
    1867                 :            : 
    1868         [ #  # ]:          0 :     if (pBox != NULL)
    1869                 :            :     {
    1870                 :          0 :         const SwFrmFmt * pFmt = pBox->GetFrmFmt();
    1871      [ #  #  # ]:          0 :         switch (pFmt->GetVertOrient().GetVertOrient())
    1872                 :            :         {
    1873                 :            :             case text::VertOrientation::CENTER:
    1874                 :          0 :                 nFlags |= (1 << 7);
    1875                 :          0 :                 break;
    1876                 :            :             case text::VertOrientation::BOTTOM:
    1877                 :          0 :                 nFlags |= (2 << 7);
    1878                 :          0 :                 break;
    1879                 :            :             default:
    1880                 :          0 :                 break;
    1881                 :            :         }
    1882                 :            :     }
    1883                 :            : 
    1884                 :          0 :     return nFlags;
    1885                 :            : }
    1886                 :            : 
    1887                 :          0 : void WW8AttributeOutput::TableVerticalCell( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1888                 :            : {
    1889                 :          0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
    1890                 :          0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
    1891                 :          0 :     const SwTableBoxes & rTblBoxes = pTabLine->GetTabBoxes();
    1892                 :            : 
    1893                 :          0 :     sal_uInt8 nBoxes = rTblBoxes.size();
    1894         [ #  # ]:          0 :     for ( sal_uInt8 n = 0; n < nBoxes; n++ )
    1895                 :            :     {
    1896                 :          0 :         const SwTableBox * pTabBox1 = rTblBoxes[n];
    1897                 :          0 :         const SwFrmFmt * pFrmFmt = pTabBox1->GetFrmFmt();
    1898                 :            : 
    1899         [ #  # ]:          0 :         if ( FRMDIR_VERT_TOP_RIGHT == m_rWW8Export.TrueFrameDirection( *pFrmFmt ) )
    1900                 :            :         {
    1901                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_TTextFlow );
    1902         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( sal_uInt8(n) );        //start range
    1903         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( sal_uInt8(n + 1) );    //end range
    1904                 :          0 :             m_rWW8Export.InsUInt16( 5 ); //Equals vertical writing
    1905                 :            :         }
    1906                 :            :     }
    1907                 :          0 : }
    1908                 :            : 
    1909                 :          0 : void WW8AttributeOutput::TableCanSplit( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1910                 :            : {
    1911         [ #  # ]:          0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
    1912                 :          0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
    1913                 :          0 :     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
    1914                 :            : 
    1915                 :            :     /*
    1916                 :            :      By default the row can be split in word, and now in writer we have a
    1917                 :            :      feature equivalent to this, Word stores 1 for fCantSplit if the row
    1918                 :            :      cannot be split, we set true if we can split it. An example is #i4569#
    1919                 :            :      */
    1920                 :            : 
    1921         [ #  # ]:          0 :     const SwFmtRowSplit& rSplittable = pLineFmt->GetRowSplit();
    1922         [ #  # ]:          0 :     sal_uInt8 nCantSplit = (!rSplittable.GetValue()) ? 1 : 0;
    1923         [ #  # ]:          0 :     if ( m_rWW8Export.bWrtWW8 )
    1924                 :            :     {
    1925         [ #  # ]:          0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_TFCantSplit );
    1926         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( nCantSplit );
    1927         [ #  # ]:          0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_TFCantSplit90 ); // also write fCantSplit90
    1928                 :            :     }
    1929                 :            :     else
    1930                 :            :     {
    1931         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( 185 );
    1932                 :            :     }
    1933         [ #  # ]:          0 :     m_rWW8Export.pO->push_back( nCantSplit );
    1934                 :          0 : }
    1935                 :            : 
    1936                 :          0 : void WW8AttributeOutput::TableBidi( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1937                 :            : {
    1938                 :          0 :     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
    1939                 :          0 :     const SwFrmFmt * pFrmFmt = pTable->GetFrmFmt();
    1940                 :            : 
    1941         [ #  # ]:          0 :     if ( m_rWW8Export.bWrtWW8 )
    1942                 :            :     {
    1943         [ #  # ]:          0 :         if ( m_rWW8Export.TrueFrameDirection(*pFrmFmt) == FRMDIR_HORI_RIGHT_TOP )
    1944                 :            :         {
    1945                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_TFBiDi );
    1946                 :          0 :             m_rWW8Export.InsUInt16( 1 );
    1947                 :            :         }
    1948                 :            :     }
    1949                 :          0 : }
    1950                 :            : 
    1951                 :          0 : void WW8AttributeOutput::TableHeight( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1952                 :            : {
    1953                 :          0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
    1954                 :          0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
    1955                 :          0 :     const SwFrmFmt * pLineFmt = pTabLine->GetFrmFmt();
    1956                 :            : 
    1957                 :            :     // Zeilenhoehe ausgeben   sprmTDyaRowHeight
    1958                 :          0 :     long nHeight = 0;
    1959                 :          0 :     const SwFmtFrmSize& rLSz = pLineFmt->GetFrmSize();
    1960 [ #  # ][ #  # ]:          0 :     if ( ATT_VAR_SIZE != rLSz.GetHeightSizeType() && rLSz.GetHeight() )
                 [ #  # ]
    1961                 :            :     {
    1962         [ #  # ]:          0 :         if ( ATT_MIN_SIZE == rLSz.GetHeightSizeType() )
    1963                 :          0 :             nHeight = rLSz.GetHeight();
    1964                 :            :         else
    1965                 :          0 :             nHeight = -rLSz.GetHeight();
    1966                 :            :     }
    1967                 :            : 
    1968         [ #  # ]:          0 :     if ( nHeight )
    1969                 :            :     {
    1970         [ #  # ]:          0 :         if ( m_rWW8Export.bWrtWW8 )
    1971                 :          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_TDyaRowHeight );
    1972                 :            :         else
    1973         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( 189 );
    1974                 :          0 :         m_rWW8Export.InsUInt16( (sal_uInt16)nHeight );
    1975                 :            :     }
    1976                 :            : 
    1977                 :          0 : }
    1978                 :            : 
    1979                 :          0 : void WW8AttributeOutput::TableOrientation( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    1980                 :            : {
    1981                 :          0 :     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
    1982                 :            : 
    1983                 :          0 :     const SwFrmFmt *pFmt = pTable->GetFrmFmt();
    1984                 :            :     OSL_ENSURE(pFmt,"Impossible");
    1985         [ #  # ]:          0 :     if (!pFmt)
    1986                 :          0 :         return;
    1987                 :            : 
    1988                 :          0 :     const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient();
    1989                 :          0 :     const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
    1990                 :            : 
    1991 [ #  # ][ #  #  :          0 :     if (
          #  #  #  #  #  
                      # ]
    1992                 :          0 :         (text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() ||
    1993                 :          0 :          text::RelOrientation::FRAME == rHori.GetRelationOrient())
    1994                 :            :         &&
    1995                 :          0 :         (text::RelOrientation::PRINT_AREA == rVert.GetRelationOrient() ||
    1996                 :          0 :          text::RelOrientation::FRAME == rVert.GetRelationOrient())
    1997                 :            :         )
    1998                 :            :     {
    1999                 :          0 :         sal_Int16 eHOri = rHori.GetHoriOrient();
    2000         [ #  # ]:          0 :         switch (eHOri)
    2001                 :            :         {
    2002                 :            :             case text::HoriOrientation::CENTER:
    2003                 :            :             case text::HoriOrientation::RIGHT:
    2004         [ #  # ]:          0 :                 if ( m_rWW8Export.bWrtWW8 )
    2005                 :          0 :                     m_rWW8Export.InsUInt16( NS_sprm::LN_TJc );
    2006                 :            :                 else
    2007         [ #  # ]:          0 :                     m_rWW8Export.pO->push_back( 182 );
    2008         [ #  # ]:          0 :                 m_rWW8Export.InsUInt16( text::HoriOrientation::RIGHT == eHOri ? 2 : 1 );
    2009                 :          0 :                 break;
    2010                 :            :             default:
    2011                 :          0 :                 break;
    2012                 :            :         }
    2013                 :            :     }
    2014                 :            : }
    2015                 :            : 
    2016                 :          0 : void WW8AttributeOutput::TableSpacing(ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner)
    2017                 :            : {
    2018                 :          0 :     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
    2019                 :          0 :     const SwTableFmt * pTableFmt = pTable->GetTableFmt();
    2020                 :            : 
    2021         [ #  # ]:          0 :     if (pTableFmt != NULL)
    2022                 :            :     {
    2023                 :          0 :         const SvxULSpaceItem & rUL = pTableFmt->GetULSpace();
    2024                 :            : 
    2025         [ #  # ]:          0 :         if (rUL.GetUpper() > 0)
    2026                 :            :         {
    2027                 :          0 :             sal_uInt8 nPadding = 2;
    2028                 :          0 :             sal_uInt8 nPcVert = 0;
    2029                 :          0 :             sal_uInt8 nPcHorz = 0;
    2030                 :            : 
    2031                 :          0 :             sal_uInt8 nTPc = (nPadding << 4) | (nPcVert << 2) | nPcHorz;
    2032                 :            : 
    2033         [ #  # ]:          0 :             m_rWW8Export.InsUInt16(NS_sprm::LN_TPc);
    2034         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( nTPc );
    2035                 :            : 
    2036         [ #  # ]:          0 :             m_rWW8Export.InsUInt16(NS_sprm::LN_TDyaAbs);
    2037         [ #  # ]:          0 :             m_rWW8Export.InsUInt16(rUL.GetUpper());
    2038                 :            : 
    2039         [ #  # ]:          0 :             m_rWW8Export.InsUInt16(NS_sprm::LN_TDyaFromText);
    2040         [ #  # ]:          0 :             m_rWW8Export.InsUInt16(rUL.GetUpper());
    2041                 :            :         }
    2042                 :            : 
    2043         [ #  # ]:          0 :         if (rUL.GetLower() > 0)
    2044                 :            :         {
    2045                 :          0 :             m_rWW8Export.InsUInt16(NS_sprm::LN_TDyaFromTextBottom);
    2046                 :          0 :             m_rWW8Export.InsUInt16(rUL.GetLower());
    2047                 :            :         }
    2048                 :            :     }
    2049                 :          0 : }
    2050                 :            : 
    2051                 :          0 : void WW8AttributeOutput::TableDefinition( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    2052                 :            : {
    2053         [ #  # ]:          0 :     const SwTable * pTable = pTableTextNodeInfoInner->getTable();
    2054                 :            : 
    2055 [ #  # ][ #  # ]:          0 :     if ( pTable->GetRowsToRepeat() > pTableTextNodeInfoInner->getRow() )
                 [ #  # ]
    2056                 :            :     {
    2057         [ #  # ]:          0 :         if( m_rWW8Export.bWrtWW8 )
    2058         [ #  # ]:          0 :             m_rWW8Export.InsUInt16( NS_sprm::LN_TTableHeader );
    2059                 :            :         else
    2060         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( 186 );
    2061         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( 1 );
    2062                 :            :     }
    2063                 :            : 
    2064                 :            :     ww8::TableBoxVectorPtr pTableBoxes =
    2065         [ #  # ]:          0 :         pTableTextNodeInfoInner->getTableBoxesOfRow();
    2066                 :            :     // number of cell written
    2067                 :          0 :     sal_uInt32 nBoxes = pTableBoxes->size();
    2068         [ #  # ]:          0 :     if (nBoxes > ww8::MAXTABLECELLS)
    2069                 :          0 :         nBoxes = ww8::MAXTABLECELLS;
    2070                 :            : 
    2071                 :            :     // sprm header
    2072         [ #  # ]:          0 :     m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTable );
    2073                 :          0 :     sal_uInt16 nSprmSize = 2 + (nBoxes + 1) * 2 + nBoxes * 20;
    2074         [ #  # ]:          0 :     m_rWW8Export.InsUInt16( nSprmSize ); // length
    2075                 :            : 
    2076                 :            :     // number of boxes
    2077         [ #  # ]:          0 :     m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes) );
    2078                 :            : 
    2079                 :            :     /* cellxs */
    2080                 :            :     /*
    2081                 :            :      ALWAYS relative when text::HoriOrientation::NONE (nPageSize + ( nPageSize / 10 )) < nTblSz,
    2082                 :            :      in that case the cell width's and table width's are not real. The table
    2083                 :            :      width is maxed and cells relative, so we need the frame (generally page)
    2084                 :            :      width that the table is in to work out the true widths.
    2085                 :            :      */
    2086                 :            :     //const bool bNewTableModel = pTbl->IsNewModel();
    2087                 :          0 :     const SwFrmFmt *pFmt = pTable->GetFrmFmt();
    2088                 :            :     OSL_ENSURE(pFmt,"Impossible");
    2089         [ #  # ]:          0 :     if (!pFmt)
    2090                 :          0 :         return;
    2091                 :            : 
    2092         [ #  # ]:          0 :     const SwFmtHoriOrient &rHori = pFmt->GetHoriOrient();
    2093         [ #  # ]:          0 :     const SwFmtVertOrient &rVert = pFmt->GetVertOrient();
    2094                 :            : 
    2095                 :          0 :     sal_uInt16 nTblOffset = 0;
    2096                 :            : 
    2097 [ #  # ][ #  #  :          0 :     if (
          #  #  #  #  #  
                      # ]
    2098                 :          0 :         (text::RelOrientation::PRINT_AREA == rHori.GetRelationOrient() ||
    2099                 :          0 :          text::RelOrientation::FRAME == rHori.GetRelationOrient())
    2100                 :            :         &&
    2101                 :          0 :         (text::RelOrientation::PRINT_AREA == rVert.GetRelationOrient() ||
    2102                 :          0 :          text::RelOrientation::FRAME == rVert.GetRelationOrient())
    2103                 :            :         )
    2104                 :            :     {
    2105                 :          0 :         sal_Int16 eHOri = rHori.GetHoriOrient();
    2106         [ #  # ]:          0 :         switch ( eHOri )
    2107                 :            :         {
    2108                 :            :             case text::HoriOrientation::CENTER:
    2109                 :            :             case text::HoriOrientation::RIGHT:
    2110                 :          0 :                 break;
    2111                 :            : 
    2112                 :            :             default:
    2113                 :          0 :                 nTblOffset = rHori.GetPos();
    2114         [ #  # ]:          0 :                 const SvxLRSpaceItem& rLRSp = pFmt->GetLRSpace();
    2115                 :          0 :                 nTblOffset += rLRSp.GetLeft();
    2116                 :          0 :                 break;
    2117                 :            :         }
    2118                 :            :     }
    2119                 :            : 
    2120         [ #  # ]:          0 :      m_rWW8Export.InsUInt16( nTblOffset );
    2121                 :            : 
    2122 [ #  # ][ #  # ]:          0 :     ww8::GridColsPtr pGridCols = GetGridCols( pTableTextNodeInfoInner );
                 [ #  # ]
    2123 [ #  # ][ #  # ]:          0 :     for ( ww8::GridCols::const_iterator it = pGridCols->begin(),
         [ #  # ][ #  # ]
    2124         [ #  # ]:          0 :               end = pGridCols->end(); it != end; ++it )
    2125                 :            :      {
    2126 [ #  # ][ #  # ]:          0 :          m_rWW8Export.InsUInt16( static_cast<sal_uInt16>( *it ) + nTblOffset );
    2127                 :            :      }
    2128                 :            : 
    2129                 :            :      /* TCs */
    2130         [ #  # ]:          0 :     ww8::RowSpansPtr pRowSpans = pTableTextNodeInfoInner->getRowSpansOfRow();
    2131         [ #  # ]:          0 :     ww8::RowSpans::const_iterator aItRowSpans = pRowSpans->begin();
    2132                 :          0 :     ww8::TableBoxVector::const_iterator aIt;
    2133         [ #  # ]:          0 :     ww8::TableBoxVector::const_iterator aItEnd = pTableBoxes->end();
    2134                 :            : 
    2135                 :            : #if OSL_DEBUG_LEVEL > 1
    2136                 :            :     size_t nRowSpans = pRowSpans->size();
    2137                 :            :     size_t nTableBoxes = pTableBoxes->size();
    2138                 :            :     (void) nRowSpans;
    2139                 :            :     (void) nTableBoxes;
    2140                 :            : #endif
    2141                 :            : 
    2142 [ #  # ][ #  # ]:          0 :     for( aIt = pTableBoxes->begin(); aIt != aItEnd; ++aIt, ++aItRowSpans)
         [ #  # ][ #  # ]
                 [ #  # ]
    2143                 :            :     {
    2144                 :            : #if OSL_DEBUG_LEVEL > 1
    2145                 :            :         sal_uInt16 npOCount = m_rWW8Export.pO->size();
    2146                 :            : #endif
    2147                 :            : 
    2148         [ #  # ]:          0 :         const SwTableBox * pTabBox1 = *aIt;
    2149                 :          0 :         const SwFrmFmt * pBoxFmt = NULL;
    2150         [ #  # ]:          0 :         if (pTabBox1 != NULL)
    2151                 :          0 :             pBoxFmt = pTabBox1->GetFrmFmt();
    2152                 :            : 
    2153         [ #  # ]:          0 :         if ( m_rWW8Export.bWrtWW8 )
    2154                 :            :         {
    2155                 :            :             sal_uInt16 nFlags =
    2156 [ #  # ][ #  # ]:          0 :                 lcl_TCFlags(pTabBox1, *aItRowSpans);
    2157         [ #  # ]:          0 :              m_rWW8Export.InsUInt16( nFlags );
    2158                 :            :         }
    2159                 :            : 
    2160                 :            :         static sal_uInt8 aNullBytes[] = { 0x0, 0x0 };
    2161                 :            : 
    2162         [ #  # ]:          0 :         m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), aNullBytes, aNullBytes+2 );   // dummy
    2163         [ #  # ]:          0 :         if (pBoxFmt != NULL)
    2164                 :            :         {
    2165         [ #  # ]:          0 :             const SvxBoxItem & rBoxItem = pBoxFmt->GetBox();
    2166                 :            : 
    2167         [ #  # ]:          0 :             m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, &rBoxItem ); // 8/16 Byte
    2168                 :            :         }
    2169                 :            :         else
    2170         [ #  # ]:          0 :             m_rWW8Export.Out_SwFmtTableBox( *m_rWW8Export.pO, NULL); // 8/16 Byte
    2171                 :            : 
    2172                 :            : #if OSL_DEBUG_LEVEL > 1
    2173                 :            :         ::std::clog << "<tclength>" << m_rWW8Export.pO->size() - npOCount << "</tclength>"
    2174                 :            :                     << ::std::endl;
    2175                 :            : #endif
    2176 [ #  # ][ #  # ]:          0 :     }
         [ #  # ][ #  # ]
    2177                 :            : }
    2178                 :            : 
    2179                 :          0 : ww8::GridColsPtr AttributeOutputBase::GetGridCols( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    2180                 :            : {
    2181                 :          0 :     return pTableTextNodeInfoInner->getGridColsOfRow(*this);
    2182                 :            : }
    2183                 :            : 
    2184                 :          0 : void AttributeOutputBase::GetTablePageSize( ww8::WW8TableNodeInfoInner * pTableTextNodeInfoInner, sal_uInt32& rPageSize, bool& rRelBoxSize )
    2185                 :            : {
    2186                 :          0 :     sal_uInt32 nPageSize = 0;
    2187                 :            : 
    2188                 :          0 :     const SwNode *pTxtNd = pTableTextNodeInfoInner->getNode( );
    2189                 :          0 :     const SwTable *pTable = pTableTextNodeInfoInner->getTable( );
    2190                 :            : 
    2191                 :          0 :     const SwFrmFmt *pFmt = pTable->GetFrmFmt();
    2192                 :            :     OSL_ENSURE(pFmt,"Impossible");
    2193         [ #  # ]:          0 :     if (!pFmt)
    2194                 :          0 :         return;
    2195                 :            : 
    2196                 :          0 :     const SwFmtFrmSize &rSize = pFmt->GetFrmSize();
    2197                 :          0 :     int nWidthPercent = rSize.GetWidthPercent();
    2198                 :          0 :     bool bManualAligned = pFmt->GetHoriOrient().GetHoriOrient() == text::HoriOrientation::NONE;
    2199 [ #  # ][ #  # ]:          0 :     if ( (pFmt->GetHoriOrient().GetHoriOrient() == text::HoriOrientation::FULL) || bManualAligned )
                 [ #  # ]
    2200                 :          0 :         nWidthPercent = 100;
    2201                 :          0 :     bool bRelBoxSize = nWidthPercent != 0;
    2202                 :          0 :     unsigned long nTblSz = static_cast<unsigned long>(rSize.GetWidth());
    2203 [ #  # ][ #  # ]:          0 :     if (nTblSz > USHRT_MAX/2 && !bRelBoxSize)
    2204                 :            :     {
    2205                 :            :         OSL_ENSURE(bRelBoxSize, "huge table width but not relative, suspicious");
    2206                 :          0 :         bRelBoxSize = true;
    2207                 :            :     }
    2208                 :            : 
    2209         [ #  # ]:          0 :     if ( bRelBoxSize )
    2210                 :            :     {
    2211                 :          0 :         Point aPt;
    2212         [ #  # ]:          0 :         SwRect aRect( pFmt->FindLayoutRect( false, &aPt ) );
    2213         [ #  # ]:          0 :         if ( aRect.IsEmpty() )
    2214                 :            :         {
    2215                 :            :             // dann besorge mal die Seitenbreite ohne Raender !!
    2216                 :            :             const SwFrmFmt* pParentFmt =
    2217         [ #  # ]:          0 :                 GetExport().mpParentFrame ?
    2218         [ #  # ]:          0 :                 &(GetExport().mpParentFrame->GetFrmFmt()) :
    2219 [ #  # ][ #  # ]:          0 :                     GetExport().pDoc->GetPageDesc(0).GetPageFmtOfNode(*pTxtNd, false);
         [ #  # ][ #  # ]
    2220         [ #  # ]:          0 :             aRect = pParentFmt->FindLayoutRect(true);
    2221         [ #  # ]:          0 :             if ( 0 == ( nPageSize = aRect.Width() ) )
    2222                 :            :             {
    2223         [ #  # ]:          0 :                 const SvxLRSpaceItem& rLR = pParentFmt->GetLRSpace();
    2224         [ #  # ]:          0 :                 nPageSize = pParentFmt->GetFrmSize().GetWidth() - rLR.GetLeft()
    2225                 :          0 :                 - rLR.GetRight();
    2226                 :            :             }
    2227                 :            :         }
    2228                 :            :         else
    2229                 :            :         {
    2230                 :          0 :             nPageSize = aRect.Width();
    2231         [ #  # ]:          0 :             if ( bManualAligned )
    2232                 :            :             {
    2233                 :            :                 // #i37571# For manually aligned tables
    2234         [ #  # ]:          0 :                 const SvxLRSpaceItem &rLR = pFmt->GetLRSpace();
    2235                 :          0 :                 nPageSize -= (rLR.GetLeft() + rLR.GetRight());
    2236                 :            :             }
    2237                 :            : 
    2238                 :            :         }
    2239                 :            : 
    2240                 :            :         OSL_ENSURE(nWidthPercent, "Impossible");
    2241         [ #  # ]:          0 :         if (nWidthPercent)
    2242                 :            :         {
    2243                 :          0 :             nPageSize *= nWidthPercent;
    2244                 :          0 :             nPageSize /= 100;
    2245                 :            :         }
    2246                 :            :     }
    2247                 :            : 
    2248                 :          0 :     rPageSize = nPageSize;
    2249                 :          0 :     rRelBoxSize = bRelBoxSize;
    2250                 :            : }
    2251                 :            : 
    2252                 :          0 : void WW8AttributeOutput::TableDefaultBorders( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    2253                 :            : {
    2254                 :          0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
    2255                 :          0 :     const SwFrmFmt * pFrmFmt = pTabBox->GetFrmFmt();
    2256                 :            : 
    2257                 :            :     //Set Default, just taken from the first cell of the first
    2258                 :            :     //row
    2259                 :            :     static sal_uInt16 aBorders[] =
    2260                 :            :     {
    2261                 :            :         BOX_LINE_TOP, BOX_LINE_LEFT,
    2262                 :            :         BOX_LINE_BOTTOM, BOX_LINE_RIGHT
    2263                 :            :     };
    2264                 :            : 
    2265         [ #  # ]:          0 :     for ( int i = 0; i < 4; ++i )
    2266                 :            :     {
    2267                 :          0 :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO, 0xD634 );
    2268         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( sal_uInt8(6) );
    2269         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( sal_uInt8(0) );
    2270         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( sal_uInt8(1) );
    2271         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( sal_uInt8(1 << i) );
    2272         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( sal_uInt8(3) );
    2273                 :            : 
    2274                 :            :         SwWW8Writer::InsUInt16( *m_rWW8Export.pO,
    2275                 :          0 :                 pFrmFmt->GetBox().GetDistance( aBorders[i] ) );
    2276                 :            :     }
    2277                 :          0 : }
    2278                 :            : 
    2279                 :          0 : void WW8AttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner )
    2280                 :            : {
    2281                 :          0 :     const SwTableBox * pTabBox = pTableTextNodeInfoInner->getTableBox();
    2282                 :          0 :     const SwTableLine * pTabLine = pTabBox->GetUpper();
    2283                 :          0 :     const SwTableBoxes & rTabBoxes = pTabLine->GetTabBoxes();
    2284                 :            : 
    2285                 :          0 :     sal_uInt8 nBoxes = rTabBoxes.size();
    2286         [ #  # ]:          0 :     if ( m_rWW8Export.bWrtWW8 )
    2287                 :          0 :         m_rWW8Export.InsUInt16( NS_sprm::LN_TDefTableShd );
    2288                 :            :     else
    2289         [ #  # ]:          0 :         m_rWW8Export.pO->push_back( (sal_uInt8)191 );
    2290         [ #  # ]:          0 :     m_rWW8Export.pO->push_back( (sal_uInt8)(nBoxes * 2) );  // Len
    2291                 :            : 
    2292         [ #  # ]:          0 :     for ( sal_uInt8 n = 0; n < nBoxes; n++ )
    2293                 :            :     {
    2294                 :          0 :         const SwTableBox * pBox1 = rTabBoxes[n];
    2295                 :          0 :         const SwFrmFmt * pFrmFmt = pBox1->GetFrmFmt();
    2296                 :          0 :         const SfxPoolItem * pI = NULL;
    2297                 :          0 :         Color aColor;
    2298                 :            : 
    2299 [ #  # ][ #  # ]:          0 :         if ( SFX_ITEM_ON == pFrmFmt->GetAttrSet().GetItemState( RES_BACKGROUND, false, &pI ) )
    2300                 :            :         {
    2301         [ #  # ]:          0 :             aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor();
    2302                 :            :         }
    2303                 :            :         else
    2304                 :          0 :             aColor = COL_AUTO;
    2305                 :            : 
    2306                 :          0 :         WW8_SHD aShd;
    2307         [ #  # ]:          0 :         m_rWW8Export.TransBrush( aColor, aShd );
    2308         [ #  # ]:          0 :         m_rWW8Export.InsUInt16( aShd.GetValue() );
    2309                 :            :     }
    2310                 :            : 
    2311         [ #  # ]:          0 :     if ( m_rWW8Export.bWrtWW8 )
    2312                 :            :     {
    2313                 :          0 :         sal_uInt32 aSprmIds[] = {NS_sprm::LN_TCellShd, NS_sprm::LN_TCellShadow};
    2314                 :          0 :         sal_uInt8 nBoxes0 = rTabBoxes.size();
    2315         [ #  # ]:          0 :         if (nBoxes0 > 21)
    2316                 :          0 :             nBoxes0 = 21;
    2317                 :            : 
    2318         [ #  # ]:          0 :         for (sal_uInt32 m = 0; m < 2; m++)
    2319                 :            :         {
    2320         [ #  # ]:          0 :             m_rWW8Export.InsUInt16( aSprmIds[m] );
    2321         [ #  # ]:          0 :             m_rWW8Export.pO->push_back( static_cast<sal_uInt8>(nBoxes0 * 10) );
    2322                 :            : 
    2323         [ #  # ]:          0 :         for ( sal_uInt8 n = 0; n < nBoxes0; n++ )
    2324                 :            :         {
    2325                 :          0 :             const SwTableBox * pBox1 = rTabBoxes[n];
    2326                 :          0 :             const SwFrmFmt * pFrmFmt = pBox1->GetFrmFmt();
    2327                 :          0 :             const SfxPoolItem * pI = NULL;
    2328                 :          0 :             Color aColor;
    2329                 :            : 
    2330         [ #  # ]:          0 :                 if ( SFX_ITEM_ON ==
    2331                 :          0 :                          pFrmFmt->GetAttrSet().
    2332         [ #  # ]:          0 :                          GetItemState( RES_BACKGROUND, false, &pI ) )
    2333                 :            :             {
    2334         [ #  # ]:          0 :                 aColor = dynamic_cast<const SvxBrushItem *>(pI)->GetColor();
    2335                 :            :             }
    2336                 :            :             else
    2337                 :          0 :                 aColor = COL_AUTO;
    2338                 :            : 
    2339                 :          0 :             WW8SHDLong aSHD;
    2340                 :          0 :             aSHD.setCvFore( 0xFF000000 );
    2341                 :            : 
    2342                 :          0 :             sal_uInt32 nBgColor = aColor.GetColor();
    2343         [ #  # ]:          0 :             if ( nBgColor == COL_AUTO )
    2344                 :          0 :                 aSHD.setCvBack( 0xFF000000 );
    2345                 :            :             else
    2346         [ #  # ]:          0 :                 aSHD.setCvBack( wwUtility::RGBToBGR( nBgColor ) );
    2347                 :            : 
    2348         [ #  # ]:          0 :             aSHD.Write( m_rWW8Export );
    2349                 :          0 :         }
    2350                 :            :         }
    2351                 :            :     }
    2352                 :          0 : }
    2353                 :            : 
    2354                 :         72 : void WW8Export::SectionBreaksAndFrames( const SwTxtNode& rNode )
    2355                 :            : {
    2356                 :            :     // output page/section breaks
    2357                 :         72 :     OutputSectionBreaks( rNode.GetpSwAttrSet(), rNode );
    2358                 :            : 
    2359                 :            :     // all textframes anchored as character for the winword 7- format
    2360 [ #  # ][ -  + ]:         72 :     if ( !bWrtWW8 && !IsInTable() )
                 [ -  + ]
    2361                 :          0 :         OutWW6FlyFrmsInCntnt( rNode );
    2362                 :         72 : }
    2363                 :            : 
    2364                 :        153 : void MSWordExportBase::WriteText()
    2365                 :            : {
    2366   [ +  +  +  +  :        912 :     while( pCurPam->GetPoint()->nNode < pCurPam->GetMark()->nNode ||
           +  - ][ +  + ]
    2367                 :        162 :            ( pCurPam->GetPoint()->nNode == pCurPam->GetMark()->nNode &&
    2368                 :        153 :              pCurPam->GetPoint()->nContent.GetIndex() <= pCurPam->GetMark()->nContent.GetIndex() ) )
    2369                 :            :     {
    2370                 :        588 :         SwNode * pNd = pCurPam->GetNode();
    2371                 :            : 
    2372         [ +  + ]:        588 :         if ( pNd->IsTxtNode() )
    2373                 :        300 :             SectionBreaksAndFrames( *pNd->GetTxtNode() );
    2374                 :            : 
    2375                 :            :         // output the various types of nodes
    2376         [ +  + ]:        588 :         if ( pNd->IsCntntNode() )
    2377                 :            :         {
    2378         [ +  - ]:        300 :             SwCntntNode* pCNd = (SwCntntNode*)pNd;
    2379                 :            : 
    2380                 :        300 :             const SwPageDesc* pTemp = pCNd->GetSwAttrSet().GetPageDesc().GetPageDesc();
    2381         [ +  + ]:        300 :             if ( pTemp )
    2382                 :        129 :                 pAktPageDesc = pTemp;
    2383                 :            : 
    2384         [ +  - ]:        300 :             pCurPam->GetPoint()->nContent.Assign( pCNd, 0 );
    2385                 :        300 :             OutputContentNode( *pCNd );
    2386                 :            :         }
    2387         [ -  + ]:        288 :         else if ( pNd->IsTableNode() )
    2388                 :            :         {
    2389                 :          0 :             mpTableInfo->processSwTable( &pNd->GetTableNode()->GetTable() );
    2390                 :            :         }
    2391 [ -  + ][ #  # ]:        288 :         else if ( pNd->IsSectionNode() && TXT_MAINTEXT == nTxtTyp )
                 [ -  + ]
    2392                 :          0 :             OutputSectionNode( *pNd->GetSectionNode() );
    2393         [ +  - ]:        432 :         else if ( TXT_MAINTEXT == nTxtTyp && pNd->IsEndNode() &&
           [ +  +  -  + ]
                 [ -  + ]
    2394                 :        144 :                   pNd->StartOfSectionNode()->IsSectionNode() )
    2395                 :            :         {
    2396                 :          0 :             const SwSection& rSect = pNd->StartOfSectionNode()->GetSectionNode()
    2397                 :          0 :                                         ->GetSection();
    2398 [ #  # ][ #  # ]:          0 :             if ( bStartTOX && TOX_CONTENT_SECTION == rSect.GetType() )
                 [ #  # ]
    2399                 :          0 :                 bStartTOX = false;
    2400                 :            : 
    2401         [ #  # ]:          0 :             SwNodeIndex aIdx( *pNd, 1 );
    2402 [ #  # ][ #  # ]:          0 :             if ( aIdx.GetNode().IsEndNode() && aIdx.GetNode().StartOfSectionNode()->IsSectionNode() )
                 [ #  # ]
    2403                 :            :                 ;
    2404         [ #  # ]:          0 :             else if ( aIdx.GetNode().IsSectionNode() )
    2405                 :            :                 ;
    2406 [ #  # ][ #  # ]:          0 :             else if ( !IsInTable() ) //No sections in table
    2407                 :            :             {
    2408         [ #  # ]:          0 :                 ReplaceCr( (char)0xc ); // Indikator fuer Page/Section-Break
    2409                 :            : 
    2410         [ #  # ]:          0 :                 const SwSectionFmt* pParentFmt = rSect.GetFmt()->GetParent();
    2411         [ #  # ]:          0 :                 if ( !pParentFmt )
    2412                 :          0 :                     pParentFmt = (SwSectionFmt*)0xFFFFFFFF;
    2413                 :            : 
    2414                 :            :                 sal_uLong nRstLnNum;
    2415         [ #  # ]:          0 :                 if ( aIdx.GetNode().IsCntntNode() )
    2416 [ #  # ][ #  # ]:          0 :                     nRstLnNum = ((SwCntntNode&)aIdx.GetNode()).GetSwAttrSet().
    2417         [ #  # ]:          0 :                                             GetLineNumber().GetStartValue();
    2418                 :            :                 else
    2419                 :          0 :                     nRstLnNum = 0;
    2420                 :            : 
    2421         [ #  # ]:          0 :                 AppendSection( pAktPageDesc, pParentFmt, nRstLnNum );
    2422         [ #  # ]:          0 :             }
    2423                 :            :         }
    2424         [ +  + ]:        288 :         else if ( pNd->IsStartNode() )
    2425                 :            :         {
    2426                 :        144 :             OutputStartNode( *pNd->GetStartNode() );
    2427                 :            :         }
    2428         [ +  - ]:        144 :         else if ( pNd->IsEndNode() )
    2429                 :            :         {
    2430                 :        144 :             OutputEndNode( *pNd->GetEndNode() );
    2431                 :            :         }
    2432                 :            : 
    2433         [ +  + ]:        588 :         if ( pNd == &pNd->GetNodes().GetEndOfContent() )
    2434                 :        144 :             break;
    2435                 :            : 
    2436                 :        444 :         SwNode * pCurrentNode = &pCurPam->GetPoint()->nNode.GetNode();
    2437                 :        444 :         const SwNode * pNextNode = mpTableInfo->getNextNode(pCurrentNode);
    2438                 :            : 
    2439         [ -  + ]:        444 :         if (pNextNode != NULL)
    2440         [ #  # ]:          0 :             pCurPam->GetPoint()->nNode = SwNodeIndex(*pNextNode);
    2441                 :            :         else
    2442                 :        444 :             pCurPam->GetPoint()->nNode++;
    2443                 :            : 
    2444                 :        444 :         sal_uLong nPos = pCurPam->GetPoint()->nNode.GetIndex();
    2445                 :        444 :         ::SetProgressState( nPos, pCurPam->GetDoc()->GetDocShell() );
    2446                 :            :     }
    2447                 :            : 
    2448                 :            : #if OSL_DEBUG_LEVEL > 1
    2449                 :            :     ::std::clog << "</WriteText>" << ::std::endl;
    2450                 :            : #endif
    2451                 :        153 : }
    2452                 :            : 
    2453                 :          9 : void WW8Export::WriteMainText()
    2454                 :            : {
    2455                 :            : #if OSL_DEBUG_LEVEL > 1
    2456                 :            :     ::std::clog << "<WriteMainText>" << ::std::endl;
    2457                 :            : #endif
    2458                 :            : 
    2459                 :          9 :     pFib->fcMin = Strm().Tell();
    2460                 :            : 
    2461                 :          9 :     pCurPam->GetPoint()->nNode = pDoc->GetNodes().GetEndOfContent().StartOfSectionNode()->GetIndex();
    2462                 :            : 
    2463                 :          9 :     WriteText();
    2464                 :            : 
    2465         [ -  + ]:          9 :     if( 0 == Strm().Tell() - pFib->fcMin )  // kein Text ?
    2466         [ #  # ]:          0 :         WriteCR();                  // dann CR ans Ende ( sonst mault WW )
    2467                 :            : 
    2468                 :          9 :     pFib->ccpText = Fc2Cp( Strm().Tell() );
    2469                 :          9 :     pFldMain->Finish( pFib->ccpText, 0 );
    2470                 :            : 
    2471                 :            :                     // ccpText beinhaltet Ftn- und KF-Texte
    2472                 :            :                     // deshalb wird pFib->ccpText evtl. noch geupdated
    2473                 :            :     // save the StyleId of the last paragraph. Because WW97 take the style
    2474                 :            :     // from the last CR, that will be write after footer/Header/fontnotes/
    2475                 :            :     // annotation usw.
    2476                 :          9 :     const SwTxtNode* pLastNd = pCurPam->GetMark()->nNode.GetNode().GetTxtNode();
    2477         [ -  + ]:          9 :     if( pLastNd )
    2478                 :          0 :         nLastFmtId = GetId( (SwTxtFmtColl&)pLastNd->GetAnyFmtColl() );
    2479                 :            : 
    2480                 :            : #if OSL_DEBUG_LEVEL > 1
    2481                 :            :     ::std::clog << "</WriteMainText>" << ::std::endl;
    2482                 :            : #endif
    2483                 :          9 : }
    2484                 :            : 
    2485                 :          0 : bool MSWordExportBase::IsInTable() const
    2486                 :            : {
    2487                 :          0 :     bool bResult = false;
    2488                 :            : 
    2489         [ #  # ]:          0 :     if (pCurPam != NULL)
    2490                 :            :     {
    2491                 :          0 :         SwNode * pNode = pCurPam->GetNode();
    2492                 :            : 
    2493 [ #  # ][ #  # ]:          0 :         if (pNode != NULL && mpTableInfo.get() != NULL)
                 [ #  # ]
    2494                 :            :         {
    2495         [ #  # ]:          0 :             ww8::WW8TableNodeInfo::Pointer_t pTableNodeInfo = mpTableInfo->getTableNodeInfo(pNode);
    2496                 :            : 
    2497 [ #  # ][ #  # ]:          0 :             if (pTableNodeInfo.get() != NULL && pTableNodeInfo->getDepth() > 0)
         [ #  # ][ #  # ]
    2498                 :            :             {
    2499                 :          0 :                 bResult = true;
    2500         [ #  # ]:          0 :             }
    2501                 :            :         }
    2502                 :            :     }
    2503                 :            : 
    2504                 :          0 :     return bResult;
    2505                 :            : }
    2506                 :            : 
    2507                 :            : typedef ww8::WW8Sttb< ww8::WW8Struct >  WW8SttbAssoc;
    2508                 :            : 
    2509                 :          9 : void WW8Export::WriteFkpPlcUsw()
    2510                 :            : {
    2511         [ -  + ]:          9 :     if( !bWrtWW8 )
    2512                 :            :     {
    2513                 :            :         static const sal_uInt8 aSpec[2] =
    2514                 :            :         {
    2515                 :            :             117, 1
    2516                 :            :         };
    2517                 :            : 
    2518                 :          0 :         pChpPlc->AppendFkpEntry( Strm().Tell() );   // Sepx mit fSpecial
    2519                 :          0 :         pSepx->WriteSepx( Strm() );                 // Slcx.Sepx
    2520                 :          0 :         pGrf->Write();                              // Grafiken
    2521                 :          0 :         pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aSpec ), aSpec );
    2522                 :            : 
    2523                 :          0 :         pChpPlc->WriteFkps();                   // Fkp.Chpx
    2524                 :          0 :         pPapPlc->WriteFkps();                   // Fkp.Papx
    2525                 :          0 :         pStyles->OutputStylesTable();           // Styles
    2526                 :          0 :         pFtn->WritePlc( *this );                // Footnote-Ref & Text Plc
    2527                 :          0 :         pEdn->WritePlc( *this );                // Endnote-Ref & Text Plc
    2528                 :          0 :         pAtn->WritePlc( *this );                // Annotation-Ref & Text Plc
    2529                 :          0 :         pSepx->WritePlcSed( *this );            // Slcx.PlcSed
    2530                 :          0 :         pSepx->WritePlcHdd( *this );            // Slcx.PlcHdd
    2531                 :          0 :         pChpPlc->WritePlc();                    // Plcx.Chpx
    2532                 :          0 :         pPapPlc->WritePlc();                    // Plcx.Papx
    2533                 :          0 :         maFontHelper.WriteFontTable(pTableStrm, *pFib); // FFNs
    2534         [ #  # ]:          0 :         if( pRedlAuthors )
    2535                 :          0 :             pRedlAuthors->Write( GetWriter() );       // sttbfRMark (RedlineAuthors)
    2536                 :          0 :         pFldMain->Write( *this );               // Fields ( Main Text )
    2537                 :          0 :         pFldHdFt->Write( *this );               // Fields ( Header/Footer )
    2538                 :          0 :         pFldFtn->Write( *this );                // Fields ( FootNotes )
    2539                 :          0 :         pFldEdn->Write( *this );                // Fields ( EndNotes )
    2540                 :          0 :         pFldAtn->Write( *this );                // Fields ( Annotations )
    2541                 :          0 :         pBkmks->Write( *this );                 // Bookmarks - sttbfBkmk/
    2542                 :            :                                                 // plcfBkmkf/plcfBkmkl
    2543                 :          0 :         WriteDop( *this );                      // Document-Properties
    2544                 :            : 
    2545                 :            :     }
    2546                 :            :     else
    2547                 :            :     {
    2548                 :            :         // Grafiken in den Data-Tream
    2549                 :          9 :         pGrf->Write();                      // Grafiken
    2550                 :            : 
    2551                 :            :         // Ausgabe in WordDocument-Stream
    2552                 :          9 :         pChpPlc->WriteFkps();                   // Fkp.Chpx
    2553                 :          9 :         pPapPlc->WriteFkps();                   // Fkp.Papx
    2554                 :          9 :         pSepx->WriteSepx( Strm() );             // Sepx
    2555                 :            : 
    2556                 :            :         // Ausagbe in Table-Stream
    2557                 :          9 :         pStyles->OutputStylesTable();           // fuer WW8 StyleTab
    2558                 :          9 :         pFtn->WritePlc( *this );                // Footnote-Ref & Text Plc
    2559                 :          9 :         pEdn->WritePlc( *this );                // Endnote-Ref & Text Plc
    2560                 :          9 :         pTxtBxs->WritePlc( *this );             // Textbox Text Plc
    2561                 :          9 :         pHFTxtBxs->WritePlc( *this );           // Head/Foot-Textbox Text Plc
    2562                 :          9 :         pAtn->WritePlc( *this );                // Annotation-Ref & Text Plc
    2563                 :            : 
    2564                 :          9 :         pSepx->WritePlcSed( *this );            // Slcx.PlcSed
    2565                 :          9 :         pSepx->WritePlcHdd( *this );            // Slcx.PlcHdd
    2566                 :            : 
    2567                 :          9 :         pChpPlc->WritePlc();                    // Plcx.Chpx
    2568                 :          9 :         pPapPlc->WritePlc();                    // Plcx.Papx
    2569                 :            : 
    2570         [ -  + ]:          9 :         if( pRedlAuthors )
    2571                 :          0 :             pRedlAuthors->Write( GetWriter() );       // sttbfRMark (RedlineAuthors)
    2572                 :          9 :         pFldMain->Write( *this );               // Fields ( Main Text )
    2573                 :          9 :         pFldHdFt->Write( *this );               // Fields ( Header/Footer )
    2574                 :          9 :         pFldFtn->Write( *this );                // Fields ( FootNotes )
    2575                 :          9 :         pFldEdn->Write( *this );                // Fields ( EndNotes )
    2576                 :          9 :         pFldAtn->Write( *this );                // Fields ( Annotations )
    2577                 :          9 :         pFldTxtBxs->Write( *this );             // Fields ( Textboxes )
    2578                 :          9 :         pFldHFTxtBxs->Write( *this );           // Fields ( Head/Foot-Textboxes )
    2579                 :            : 
    2580 [ -  + ][ +  + ]:          9 :         if (pEscher || pDoc->ContainsMSVBasic())
                 [ +  + ]
    2581                 :            :         {
    2582                 :            :             /*
    2583                 :            :              Everytime MS 2000 creates an escher stream there is always
    2584                 :            :              an ObjectPool dir (even if empty). It turns out that if a copy of
    2585                 :            :              MS 2000 is used to open a document that contains escher graphics
    2586                 :            :              exported from StarOffice without this empty dir then *if* that
    2587                 :            :              copy of MS Office has never been used to open a MSOffice document
    2588                 :            :              that has escher graphics (and an ObjectPool dir of course) and
    2589                 :            :              that copy of office has not been used to draw escher graphics then
    2590                 :            :              our exported graphics do not appear. Once you do open a ms
    2591                 :            :              document with escher graphics or draw an escher graphic with that
    2592                 :            :              copy of word, then all documents from staroffice that contain
    2593                 :            :              escher work from then on. Tricky to track down, some sort of late
    2594                 :            :              binding trickery in MS where solely for first time initialization
    2595                 :            :              the existence of an ObjectPool dir is necessary for triggering
    2596                 :            :              some magic. cmc
    2597                 :            :             */
    2598                 :            :             /* Similiarly having msvbasic storage seems to also trigger creating this stream */
    2599                 :          6 :             GetWriter().GetStorage().OpenSotStorage(rtl::OUString(SL::aObjectPool),
    2600   [ +  -  +  - ]:         12 :                 STREAM_READWRITE | STREAM_SHARE_DENYALL);
                 [ +  - ]
    2601                 :            :         }
    2602                 :            : 
    2603                 :            :         // dggInfo - escher stream
    2604                 :          9 :         WriteEscher();
    2605                 :            : 
    2606                 :          9 :         pSdrObjs->WritePlc( *this );
    2607                 :          9 :         pHFSdrObjs->WritePlc( *this );
    2608                 :            :         // spamom - office drawing table
    2609                 :            :         // spahdr - header office drawing table
    2610                 :            : 
    2611                 :          9 :         pBkmks->Write( *this );                 // Bookmarks - sttbfBkmk/
    2612                 :            :                                                 // plcfBkmkf/plcfBkmkl
    2613                 :            : 
    2614                 :          9 :         WriteNumbering();
    2615                 :            : 
    2616                 :          9 :         RestoreMacroCmds();
    2617                 :            : 
    2618                 :          9 :         pMagicTable->Write( *this );
    2619                 :            : 
    2620                 :          9 :         pPiece->WritePc( *this );               // Piece-Table
    2621                 :          9 :         maFontHelper.WriteFontTable(pTableStrm, *pFib); // FFNs
    2622                 :            : 
    2623                 :            :         //Convert OOo asian typography into MS typography structure
    2624                 :          9 :         ExportDopTypography(pDop->doptypography);
    2625                 :            : 
    2626                 :          9 :         WriteDop( *this );                      // Document-Properties
    2627                 :            : 
    2628                 :            :         // Write SttbfAssoc
    2629                 :            :         WW8SttbAssoc * pSttbfAssoc = dynamic_cast<WW8SttbAssoc *>
    2630         [ +  + ]:          9 :             (pDoc->getExternalData(::sw::STTBF_ASSOC).get());
    2631                 :            : 
    2632         [ +  + ]:          9 :         if ( pSttbfAssoc )                      // #i106057#
    2633                 :            :         {
    2634         [ +  - ]:          3 :         ::std::vector<rtl::OUString> aStrings;
    2635                 :            : 
    2636                 :          3 :         ::ww8::StringVector_t & aSttbStrings = pSttbfAssoc->getStrings();
    2637         [ +  - ]:          3 :         ::ww8::StringVector_t::const_iterator aItEnd = aSttbStrings.end();
    2638 [ +  - ][ +  - ]:         57 :         for (::ww8::StringVector_t::const_iterator aIt = aSttbStrings.begin();
                 [ +  + ]
    2639                 :            :              aIt != aItEnd; ++aIt)
    2640                 :            :         {
    2641         [ +  - ]:         54 :             aStrings.push_back(aIt->getStr());
    2642                 :            :         }
    2643                 :            : 
    2644                 :            :         WriteAsStringTable(aStrings, pFib->fcSttbfAssoc,
    2645         [ +  - ]:          3 :                            pFib->lcbSttbfAssoc);
    2646                 :            :         }
    2647                 :            :     }
    2648                 :          9 :     Strm().Seek( 0 );
    2649                 :            : 
    2650                 :            :     // Reclaim stored FIB data from document.
    2651                 :            :     ::ww8::WW8FibData * pFibData = dynamic_cast<ww8::WW8FibData *>
    2652         [ +  + ]:          9 :           (pDoc->getExternalData(::sw::FIB).get());
    2653                 :            : 
    2654         [ +  + ]:          9 :     if ( pFibData )
    2655                 :            :     {
    2656                 :            :     pFib->fReadOnlyRecommended =
    2657         [ -  + ]:          3 :         pFibData->getReadOnlyRecommended() ? 1 : 0;
    2658                 :            :     pFib->fWriteReservation =
    2659         [ -  + ]:          3 :         pFibData->getWriteReservation() ? 1 : 0;
    2660                 :            :     }
    2661                 :            : 
    2662                 :          9 :     pFib->Write( Strm() );  // FIB
    2663                 :          9 : }
    2664                 :            : 
    2665                 :          9 : void WW8Export::StoreDoc1()
    2666                 :            : {
    2667                 :          9 :     bool bNeedsFinalPara = false;
    2668                 :            :     // Start of Text ( Mangel ueber )
    2669 [ +  - ][ +  - ]:          9 :     SwWW8Writer::FillUntil( Strm(), pFib->fcMin );
    2670                 :            : 
    2671         [ +  - ]:          9 :     WriteMainText();                    // HauptText
    2672                 :            :     sal_uInt8 nSprmsLen;
    2673         [ +  - ]:          9 :     sal_uInt8 *pLastSprms = pPapPlc->CopyLastSprms(nSprmsLen);
    2674                 :            : 
    2675         [ +  - ]:          9 :     bNeedsFinalPara |= pFtn->WriteTxt( *this );         // Footnote-Text
    2676         [ +  - ]:          9 :     bNeedsFinalPara |= pSepx->WriteKFTxt( *this );          // K/F-Text
    2677         [ +  - ]:          9 :     bNeedsFinalPara |= pAtn->WriteTxt( *this );         // Annotation-Text
    2678         [ +  - ]:          9 :     bNeedsFinalPara |= pEdn->WriteTxt( *this );         // EndNote-Text
    2679                 :            : 
    2680                 :            :     // create the escher streams
    2681         [ +  - ]:          9 :     if( bWrtWW8 )
    2682         [ +  - ]:          9 :         CreateEscher();
    2683                 :            : 
    2684         [ +  - ]:          9 :     bNeedsFinalPara |= pTxtBxs->WriteTxt( *this );  //Textbox Text Plc
    2685         [ +  - ]:          9 :     bNeedsFinalPara |= pHFTxtBxs->WriteTxt( *this );//Head/Foot-Textbox Text Plc
    2686                 :            : 
    2687         [ +  - ]:          9 :     if (bNeedsFinalPara)
    2688                 :            :     {
    2689 [ +  - ][ +  - ]:          9 :         WriteCR();
                 [ +  - ]
    2690 [ +  - ][ +  - ]:          9 :         pPapPlc->AppendFkpEntry(Strm().Tell(), nSprmsLen, pLastSprms);
    2691                 :            :     }
    2692         [ +  - ]:          9 :     delete[] pLastSprms;
    2693                 :            : 
    2694 [ +  - ][ +  - ]:          9 :     pSepx->Finish( Fc2Cp( Strm().Tell() ));// Text + Ftn + HdFt als Section-Ende
                 [ +  - ]
    2695 [ +  - ][ +  - ]:          9 :     pMagicTable->Finish( Fc2Cp( Strm().Tell() ),0);
                 [ +  - ]
    2696                 :            : 
    2697         [ +  - ]:          9 :     pFib->fcMac = Strm().Tell();        // Ende aller Texte
    2698                 :            : 
    2699         [ +  - ]:          9 :     WriteFkpPlcUsw();                   // FKP, PLC, .....
    2700                 :          9 : }
    2701                 :            : 
    2702                 :          3 : void MSWordExportBase::AddLinkTarget(const String& rURL)
    2703                 :            : {
    2704 [ +  - ][ +  - ]:          3 :     if( !rURL.Len() || rURL.GetChar(0) != INET_MARK_TOKEN )
                 [ -  + ]
    2705                 :            :         return;
    2706                 :            : 
    2707 [ #  # ][ #  # ]:          0 :     String aURL( BookmarkToWriter( rURL.Copy( 1 ) ) );
                 [ #  # ]
    2708         [ #  # ]:          0 :     xub_StrLen nPos = aURL.SearchBackward( cMarkSeperator );
    2709                 :            : 
    2710         [ #  # ]:          0 :     if( nPos < 2 )
    2711                 :            :         return;
    2712                 :            : 
    2713 [ #  # ][ #  # ]:          0 :     String sCmp(comphelper::string::remove(aURL.Copy(nPos+1), ' '));
         [ #  # ][ #  # ]
    2714         [ #  # ]:          0 :     if( !sCmp.Len() )
    2715                 :            :         return;
    2716                 :            : 
    2717         [ #  # ]:          0 :     sCmp.ToLowerAscii();
    2718                 :            : 
    2719 [ #  # ][ #  # ]:          0 :     if( sCmp.EqualsAscii( pMarkToOutline ) )
    2720                 :            :     {
    2721         [ #  # ]:          0 :         SwPosition aPos( *pCurPam->GetPoint() );
    2722 [ #  # ][ #  # ]:          0 :         String aOutline( BookmarkToWriter(aURL.Copy( 0, nPos )) );
                 [ #  # ]
    2723                 :            :         // If we can find the outline this bookmark refers to
    2724                 :            :         // save the name of the bookmark and the
    2725                 :            :         // node index number of where it points to
    2726 [ #  # ][ #  # ]:          0 :         if( pDoc->GotoOutline( aPos, aOutline ) )
    2727                 :            :         {
    2728                 :          0 :             sal_uLong nIdx = aPos.nNode.GetIndex();
    2729         [ #  # ]:          0 :             aBookmarkPair aImplicitBookmark;
    2730         [ #  # ]:          0 :             aImplicitBookmark.first = aOutline;
    2731                 :          0 :             aImplicitBookmark.second = nIdx;
    2732 [ #  # ][ #  # ]:          0 :             maImplicitBookmarks.push_back(aImplicitBookmark);
    2733 [ #  # ][ #  # ]:          0 :         }
    2734 [ #  # ][ #  # ]:          3 :     }
         [ #  # ][ #  # ]
    2735                 :            : }
    2736                 :            : 
    2737                 :        144 : void MSWordExportBase::CollectOutlineBookmarks(const SwDoc &rDoc)
    2738                 :            : {
    2739                 :            :     const SwFmtINetFmt* pINetFmt;
    2740                 :            :     const SwTxtINetFmt* pTxtAttr;
    2741                 :            :     const SwTxtNode* pTxtNd;
    2742                 :            : 
    2743                 :        144 :     sal_uInt32 n, nMaxItems = rDoc.GetAttrPool().GetItemCount2( RES_TXTATR_INETFMT );
    2744         [ +  + ]:        153 :     for( n = 0; n < nMaxItems; ++n )
    2745                 :            :     {
    2746 [ +  + ][ +  - ]:         12 :         if( 0 != (pINetFmt = (SwFmtINetFmt*)rDoc.GetAttrPool().GetItem2(
           [ +  -  +  - ]
                 [ +  + ]
    2747                 :          9 :             RES_TXTATR_INETFMT, n ) ) &&
    2748                 :            :             0 != ( pTxtAttr = pINetFmt->GetTxtINetFmt()) &&
    2749                 :            :             0 != ( pTxtNd = pTxtAttr->GetpTxtNode() ) &&
    2750                 :          3 :             pTxtNd->GetNodes().IsDocNodes() )
    2751                 :            :         {
    2752                 :          3 :             AddLinkTarget( pINetFmt->GetValue() );
    2753                 :            :         }
    2754                 :            :     }
    2755                 :            : 
    2756                 :            :     const SwFmtURL *pURL;
    2757                 :        144 :     nMaxItems = rDoc.GetAttrPool().GetItemCount2( RES_URL );
    2758         [ -  + ]:        144 :     for( n = 0; n < nMaxItems; ++n )
    2759                 :            :     {
    2760         [ #  # ]:          0 :         if( 0 != (pURL = (SwFmtURL*)rDoc.GetAttrPool().GetItem2(
    2761                 :          0 :             RES_URL, n ) ) )
    2762                 :            :         {
    2763                 :          0 :             AddLinkTarget( pURL->GetURL() );
    2764                 :          0 :             const ImageMap *pIMap = pURL->GetMap();
    2765         [ #  # ]:          0 :             if( pIMap )
    2766                 :            :             {
    2767         [ #  # ]:          0 :                 for( sal_uInt16 i=0; i<pIMap->GetIMapObjectCount(); i++ )
    2768                 :            :                 {
    2769                 :          0 :                     const IMapObject* pObj = pIMap->GetIMapObject( i );
    2770         [ #  # ]:          0 :                     if( pObj )
    2771                 :            :                     {
    2772                 :          0 :                         AddLinkTarget( pObj->GetURL() );
    2773                 :            :                     }
    2774                 :            :                 }
    2775                 :            :             }
    2776                 :            :         }
    2777                 :            :     }
    2778                 :        144 : }
    2779                 :            : 
    2780                 :            : namespace
    2781                 :            : {
    2782                 :            :     const sal_uLong WW_BLOCKSIZE = 0x200;
    2783                 :            : 
    2784                 :          0 :     void EncryptRC4(msfilter::MSCodec_Std97& rCtx, SvStream &rIn, SvStream &rOut)
    2785                 :            :     {
    2786         [ #  # ]:          0 :         rIn.Seek(STREAM_SEEK_TO_END);
    2787                 :          0 :         sal_uLong nLen = rIn.Tell();
    2788         [ #  # ]:          0 :         rIn.Seek(0);
    2789                 :            : 
    2790                 :            :         sal_uInt8 in[WW_BLOCKSIZE];
    2791         [ #  # ]:          0 :         for (sal_Size nI = 0, nBlock = 0; nI < nLen; nI += WW_BLOCKSIZE, ++nBlock)
    2792                 :            :         {
    2793                 :          0 :             sal_Size nBS = (nLen - nI > WW_BLOCKSIZE) ? WW_BLOCKSIZE : nLen - nI;
    2794         [ #  # ]:          0 :             nBS = rIn.Read(in, nBS);
    2795         [ #  # ]:          0 :             rCtx.InitCipher(nBlock);
    2796         [ #  # ]:          0 :             rCtx.Encode(in, nBS, in, nBS);
    2797         [ #  # ]:          0 :             rOut.Write(in, nBS);
    2798                 :            :         }
    2799                 :          0 :     }
    2800                 :            : }
    2801                 :            : 
    2802                 :        144 : void MSWordExportBase::ExportDocument( bool bWriteAll )
    2803                 :            : {
    2804                 :        144 :     nCharFmtStart = ANZ_DEFAULT_STYLES;
    2805                 :        144 :     nFmtCollStart = nCharFmtStart + pDoc->GetCharFmts()->size() - 1;
    2806                 :            : 
    2807                 :            :     bStyDef = bBreakBefore = bOutKF =
    2808                 :            :         bOutFlyFrmAttrs = bOutPageDescs = bOutTable = bOutFirstPage =
    2809                 :            :         bOutGrf = bInWriteEscher = bStartTOX =
    2810                 :        144 :         bInWriteTOX = false;
    2811                 :            : 
    2812                 :        144 :     bFtnAtTxtEnd = bEndAtTxtEnd = true;
    2813                 :            : 
    2814                 :        144 :     mpParentFrame = 0;
    2815                 :        144 :     pFlyOffset = 0;
    2816                 :        144 :     eNewAnchorType = FLY_AT_PAGE;
    2817                 :        144 :     nTxtTyp = TXT_MAINTEXT;
    2818                 :        144 :     nStyleBeforeFly = nLastFmtId = 0;
    2819                 :        144 :     pStyAttr = 0;
    2820                 :        144 :     pCurrentStyle = NULL;
    2821                 :        144 :     pOutFmtNode = 0;
    2822                 :        144 :     pEscher = 0;
    2823                 :        144 :     pRedlAuthors = 0;
    2824                 :        144 :     aTOXArr.clear();
    2825                 :            : 
    2826         [ +  - ]:        144 :     if ( !pOLEExp )
    2827                 :            :     {
    2828                 :        144 :         sal_uInt32 nSvxMSDffOLEConvFlags = 0;
    2829                 :        144 :         const SvtFilterOptions& rOpt = SvtFilterOptions::Get();
    2830         [ +  - ]:        144 :         if ( rOpt.IsMath2MathType() )
    2831                 :        144 :             nSvxMSDffOLEConvFlags |= OLE_STARMATH_2_MATHTYPE;
    2832         [ +  - ]:        144 :         if ( rOpt.IsWriter2WinWord() )
    2833                 :        144 :             nSvxMSDffOLEConvFlags |= OLE_STARWRITER_2_WINWORD;
    2834         [ +  - ]:        144 :         if ( rOpt.IsCalc2Excel() )
    2835                 :        144 :             nSvxMSDffOLEConvFlags |= OLE_STARCALC_2_EXCEL;
    2836         [ +  - ]:        144 :         if ( rOpt.IsImpress2PowerPoint() )
    2837                 :        144 :             nSvxMSDffOLEConvFlags |= OLE_STARIMPRESS_2_POWERPOINT;
    2838                 :            : 
    2839                 :        144 :         pOLEExp = new SvxMSExportOLEObjects( nSvxMSDffOLEConvFlags );
    2840                 :            :     }
    2841                 :            : 
    2842 [ +  - ][ +  - ]:        144 :     if ( !pOCXExp && pDoc->GetDocShell() )
                 [ +  - ]
    2843         [ +  - ]:        144 :         pOCXExp = new SwMSConvertControls( pDoc->GetDocShell(), pCurPam );
    2844                 :            : 
    2845                 :            :     // #i81405# - Collect anchored objects before changing the redline mode.
    2846         [ +  - ]:        144 :     maFrames = GetFrames( *pDoc, bWriteAll? NULL : pOrigPam );
    2847                 :            : 
    2848                 :        144 :     mnRedlineMode = pDoc->GetRedlineMode();
    2849         [ -  + ]:        144 :     if ( !pDoc->GetRedlineTbl().empty() )
    2850                 :            :     {
    2851                 :            :         pDoc->SetRedlineMode( (RedlineMode_t)(mnRedlineMode | nsRedlineMode_t::REDLINE_SHOW_DELETE |
    2852                 :          0 :                                      nsRedlineMode_t::REDLINE_SHOW_INSERT) );
    2853                 :            :     }
    2854                 :            : 
    2855                 :        144 :     maFontHelper.InitFontTable( SupportsUnicode(), *pDoc );
    2856                 :        144 :     GatherChapterFields();
    2857                 :            : 
    2858                 :        144 :     CollectOutlineBookmarks(*pDoc);
    2859                 :            : 
    2860                 :            :     // make unique OrdNums (Z-Order) for all drawing-/fly Objects
    2861         [ +  - ]:        144 :     if ( pDoc->GetDrawModel() )
    2862                 :        144 :         pDoc->GetDrawModel()->GetPage( 0 )->RecalcObjOrdNums();
    2863                 :            : 
    2864                 :        144 :     ExportDocument_Impl();
    2865                 :            : 
    2866         [ -  + ]:        144 :     if ( mnRedlineMode != pDoc->GetRedlineMode() )
    2867                 :          0 :         pDoc->SetRedlineMode( (RedlineMode_t)(mnRedlineMode) );
    2868                 :        144 : }
    2869                 :            : 
    2870                 :          9 : bool SwWW8Writer::InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec )
    2871                 :            : {
    2872         [ +  - ]:          9 :     uno::Sequence< beans::NamedValue > aEncryptionData;
    2873                 :            : 
    2874         [ +  - ]:          9 :     if ( mpMedium )
    2875                 :            :     {
    2876 [ +  - ][ +  - ]:          9 :         SFX_ITEMSET_ARG( mpMedium->GetItemSet(), pEncryptionDataItem, SfxUnoAnyItem, SID_ENCRYPTIONDATA, sal_False );
                 [ +  - ]
    2877 [ -  + ][ #  # ]:          9 :         if ( pEncryptionDataItem && ( pEncryptionDataItem->GetValue() >>= aEncryptionData ) && !rCodec.InitCodec( aEncryptionData ) )
         [ #  # ][ #  # ]
         [ #  # ][ -  + ]
           [ -  +  #  # ]
    2878                 :            :         {
    2879                 :            :             OSL_ENSURE( false, "Unexpected EncryptionData!" );
    2880         [ #  # ]:          0 :             aEncryptionData.realloc( 0 );
    2881                 :            :         }
    2882                 :            : 
    2883         [ +  - ]:          9 :         if ( !aEncryptionData.getLength() )
    2884                 :            :         {
    2885                 :            :             // try to generate the encryption data based on password
    2886 [ +  - ][ +  - ]:          9 :             SFX_ITEMSET_ARG( mpMedium->GetItemSet(), pPasswordItem, SfxStringItem, SID_PASSWORD, sal_False );
                 [ +  - ]
    2887 [ -  + ][ #  # ]:          9 :             if ( pPasswordItem && pPasswordItem->GetValue().Len() && pPasswordItem->GetValue().Len() <= 15 )
         [ #  # ][ -  + ]
    2888                 :            :             {
    2889                 :            :                 // Generate random number with a seed of time as salt.
    2890                 :            :                 TimeValue aTime;
    2891         [ #  # ]:          0 :                 osl_getSystemTime( &aTime );
    2892                 :          0 :                 rtlRandomPool aRandomPool = rtl_random_createPool ();
    2893                 :          0 :                 rtl_random_addBytes ( aRandomPool, &aTime, 8 );
    2894                 :            : 
    2895                 :            :                 sal_uInt8 pDocId[ 16 ];
    2896                 :          0 :                 rtl_random_getBytes( aRandomPool, pDocId, 16 );
    2897                 :            : 
    2898                 :          0 :                 rtl_random_destroyPool( aRandomPool );
    2899                 :            : 
    2900                 :            :                 sal_Unicode aPassword[16];
    2901                 :          0 :                 memset( aPassword, 0, sizeof( aPassword ) );
    2902         [ #  # ]:          0 :                 for ( xub_StrLen nChar = 0; nChar < pPasswordItem->GetValue().Len(); ++nChar )
    2903                 :          0 :                     aPassword[nChar] = pPasswordItem->GetValue().GetChar(nChar);
    2904                 :            : 
    2905         [ #  # ]:          0 :                 rCodec.InitKey( aPassword, pDocId );
    2906 [ #  # ][ #  # ]:          0 :                 aEncryptionData = rCodec.GetEncryptionData();
                 [ #  # ]
    2907                 :            : 
    2908 [ #  # ][ #  # ]:          0 :                 mpMedium->GetItemSet()->Put( SfxUnoAnyItem( SID_ENCRYPTIONDATA, uno::makeAny( aEncryptionData ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    2909                 :            :             }
    2910                 :            :         }
    2911                 :            : 
    2912         [ -  + ]:          9 :         if ( aEncryptionData.getLength() )
    2913 [ #  # ][ #  # ]:          0 :             mpMedium->GetItemSet()->ClearItem( SID_PASSWORD );
    2914                 :            :     }
    2915                 :            : 
    2916                 :            :     // nonempty encryption data means hier that the codec was successfuly initialized
    2917         [ +  - ]:          9 :     return ( aEncryptionData.getLength() != 0 );
    2918                 :            : }
    2919                 :            : 
    2920                 :          9 : void WW8Export::ExportDocument_Impl()
    2921                 :            : {
    2922         [ +  - ]:          9 :     PrepareStorage();
    2923                 :            : 
    2924 [ +  - ][ +  - ]:          9 :     pFib = new WW8Fib( bWrtWW8 ? 8 : 6 );
                 [ +  - ]
    2925                 :            : 
    2926         [ +  - ]:          9 :     SvStorageStreamRef xWwStrm( GetWriter().GetStorage().OpenSotStream( aMainStg ) );
    2927                 :          9 :     SvStorageStreamRef xTableStrm( xWwStrm ), xDataStrm( xWwStrm );
    2928         [ +  - ]:          9 :     xWwStrm->SetBufferSize( 32768 );
    2929                 :            : 
    2930         [ +  - ]:          9 :     if( bWrtWW8 )
    2931                 :            :     {
    2932                 :          9 :         pFib->fWhichTblStm = 1;
    2933                 :          9 :         xTableStrm = GetWriter().GetStorage().OpenSotStream(rtl::OUString(SL::a1Table),
    2934   [ +  -  +  - ]:         18 :             STREAM_STD_WRITE );
         [ +  - ][ +  - ]
    2935                 :          9 :         xDataStrm = GetWriter().GetStorage().OpenSotStream(rtl::OUString(SL::aData),
    2936 [ +  - ][ +  - ]:         18 :             STREAM_STD_WRITE );
           [ +  -  +  - ]
    2937                 :            : 
    2938         [ +  - ]:          9 :         xDataStrm->SetBufferSize( 32768 );  // fuer Grafiken
    2939         [ +  - ]:          9 :         xTableStrm->SetBufferSize( 16384 ); // fuer die Font-/Style-Table, usw.
    2940                 :            : 
    2941         [ +  - ]:          9 :         xTableStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
    2942         [ +  - ]:          9 :         xDataStrm->SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
    2943                 :            :     }
    2944                 :            : 
    2945         [ +  - ]:          9 :     GetWriter().SetStream( & *xWwStrm );
    2946                 :          9 :     pTableStrm = &xTableStrm;
    2947                 :          9 :     pDataStrm = &xDataStrm;
    2948                 :            : 
    2949 [ +  - ][ +  - ]:          9 :     Strm().SetNumberFormatInt( NUMBERFORMAT_INT_LITTLEENDIAN );
    2950                 :            : 
    2951         [ +  - ]:          9 :     utl::TempFile aTempMain;
    2952                 :          9 :     aTempMain.EnableKillingFile();
    2953         [ +  - ]:          9 :     utl::TempFile aTempTable;
    2954                 :          9 :     aTempTable.EnableKillingFile();
    2955         [ +  - ]:          9 :     utl::TempFile aTempData;
    2956                 :          9 :     aTempData.EnableKillingFile();
    2957                 :            : 
    2958         [ +  - ]:          9 :     msfilter::MSCodec_Std97 aCtx;
    2959 [ +  - ][ +  - ]:          9 :     bool bEncrypt = m_pWriter ? m_pWriter->InitStd97CodecUpdateMedium( aCtx ) : false;
    2960         [ -  + ]:          9 :     if ( bEncrypt )
    2961                 :            :     {
    2962                 :          0 :         GetWriter().SetStream(
    2963   [ #  #  #  # ]:          0 :             aTempMain.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE ) );
    2964                 :            : 
    2965         [ #  # ]:          0 :         pTableStrm = aTempTable.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
    2966                 :            : 
    2967         [ #  # ]:          0 :         pDataStrm = aTempData.GetStream( STREAM_READWRITE | STREAM_SHARE_DENYWRITE );
    2968                 :            : 
    2969                 :          0 :         sal_uInt8 aRC4EncryptionHeader[ 52 ] = {0};
    2970         [ #  # ]:          0 :         pTableStrm->Write( aRC4EncryptionHeader, 52 );
    2971                 :            :     }
    2972                 :            : 
    2973                 :            :     // Default: "Standard"
    2974 [ +  - ][ +  - ]:          9 :     pSepx = new WW8_WrPlcSepx( *this );                         // Sections/headers/footers
    2975                 :            : 
    2976 [ +  - ][ +  - ]:          9 :     pFtn = new WW8_WrPlcFtnEdn( TXT_FTN );                      // Footnotes
    2977 [ +  - ][ +  - ]:          9 :     pEdn = new WW8_WrPlcFtnEdn( TXT_EDN );                      // Endnotes
    2978 [ +  - ][ +  - ]:          9 :     pAtn = new WW8_WrPlcAnnotations;                                 // PostIts
    2979 [ +  - ][ +  - ]:          9 :     pTxtBxs = new WW8_WrPlcTxtBoxes( TXT_TXTBOX );
    2980 [ +  - ][ +  - ]:          9 :     pHFTxtBxs = new WW8_WrPlcTxtBoxes( TXT_HFTXTBOX );
    2981                 :            : 
    2982 [ +  - ][ +  - ]:          9 :     pSdrObjs = new MainTxtPlcDrawObj;   // Draw-/Fly-Objects for main text
    2983 [ +  - ][ +  - ]:          9 :     pHFSdrObjs = new HdFtPlcDrawObj;    // Draw-/Fly-Objects for header/footer
    2984                 :            : 
    2985 [ +  - ][ +  - ]:          9 :     pBkmks = new WW8_WrtBookmarks;                          // Bookmarks
    2986         [ +  - ]:          9 :     GetWriter().CreateBookmarkTbl();
    2987                 :            : 
    2988 [ +  - ][ +  - ]:          9 :     pPapPlc = new WW8_WrPlcPn( *this, PAP, pFib->fcMin );
    2989 [ +  - ][ +  - ]:          9 :     pChpPlc = new WW8_WrPlcPn( *this, CHP, pFib->fcMin );
    2990 [ +  - ][ +  - ]:          9 :     pO = new ww::bytes();
    2991 [ +  - ][ +  - ]:          9 :     pStyles = new MSWordStyles( *this );
    2992 [ +  - ][ +  - ]:          9 :     pFldMain = new WW8_WrPlcFld( 2, TXT_MAINTEXT );
    2993 [ +  - ][ +  - ]:          9 :     pFldHdFt = new WW8_WrPlcFld( 2, TXT_HDFT );
    2994 [ +  - ][ +  - ]:          9 :     pFldFtn = new WW8_WrPlcFld( 2, TXT_FTN );
    2995 [ +  - ][ +  - ]:          9 :     pFldEdn = new WW8_WrPlcFld( 2, TXT_EDN );
    2996 [ +  - ][ +  - ]:          9 :     pFldAtn = new WW8_WrPlcFld( 2, TXT_ATN );
    2997 [ +  - ][ +  - ]:          9 :     pFldTxtBxs = new WW8_WrPlcFld( 2, TXT_TXTBOX );
    2998 [ +  - ][ +  - ]:          9 :     pFldHFTxtBxs = new WW8_WrPlcFld( 2, TXT_HFTXTBOX );
    2999                 :            : 
    3000 [ +  - ][ +  - ]:          9 :     pMagicTable = new WW8_WrMagicTable;
    3001                 :            : 
    3002 [ +  - ][ +  - ]:          9 :     pGrf = new SwWW8WrGrf( *this );
    3003 [ +  - ][ +  - ]:          9 :     pPiece = new WW8_WrPct( pFib->fcMin, bWrtWW8 );
    3004 [ +  - ][ +  - ]:          9 :     pDop = new WW8Dop;
    3005                 :            : 
    3006                 :            : 
    3007                 :          9 :     pDop->fRevMarking = 0 != ( nsRedlineMode_t::REDLINE_ON & mnRedlineMode );
    3008                 :          9 :     pDop->fRMView = 0 != ( nsRedlineMode_t::REDLINE_SHOW_DELETE & mnRedlineMode );
    3009                 :          9 :     pDop->fRMPrint = pDop->fRMView;
    3010                 :            : 
    3011                 :            :     // set AutoHyphenation flag if found in default para style
    3012                 :            :     const SfxPoolItem* pItem;
    3013                 :            :     SwTxtFmtColl* pStdTxtFmtColl =
    3014         [ +  - ]:          9 :         pDoc->GetTxtCollFromPool(RES_POOLCOLL_STANDARD, false);
    3015 [ +  - ][ +  + ]:         18 :     if (pStdTxtFmtColl && SFX_ITEM_SET == pStdTxtFmtColl->GetItemState(
                 [ +  + ]
    3016         [ +  - ]:          9 :         RES_PARATR_HYPHENZONE, false, &pItem))
    3017                 :            :     {
    3018                 :          3 :         pDop->fAutoHyphen = ((const SvxHyphenZoneItem*)pItem)->IsHyphen();
    3019                 :            :     }
    3020                 :            : 
    3021         [ +  - ]:          9 :     StoreDoc1();
    3022                 :            : 
    3023         [ -  + ]:          9 :     if ( bEncrypt )
    3024                 :            :     {
    3025                 :            :         SvStream *pStrmTemp, *pTableStrmTemp, *pDataStrmTemp;
    3026                 :          0 :         pStrmTemp = &xWwStrm;
    3027                 :          0 :         pTableStrmTemp = &xTableStrm;
    3028                 :          0 :         pDataStrmTemp = &xDataStrm;
    3029                 :            : 
    3030 [ #  # ][ #  # ]:          0 :         if ( pDataStrmTemp && pDataStrmTemp != pStrmTemp)
    3031         [ #  # ]:          0 :             EncryptRC4(aCtx, *pDataStrm, *pDataStrmTemp);
    3032                 :            : 
    3033         [ #  # ]:          0 :         EncryptRC4(aCtx, *pTableStrm, *pTableStrmTemp);
    3034                 :            : 
    3035                 :            :         // Write Unencrypted Header 52 bytes to the start of the table stream
    3036                 :            :         // EncryptionVersionInfo (4 bytes): A Version structure where Version.vMajor MUST be 0x0001, and Version.vMinor MUST be 0x0001.
    3037         [ #  # ]:          0 :         pTableStrmTemp->Seek( 0 );
    3038                 :          0 :         sal_uInt32 nEncType = 0x10001;
    3039         [ #  # ]:          0 :         *pTableStrmTemp << nEncType;
    3040                 :            : 
    3041                 :            :         sal_uInt8 pDocId[16];
    3042         [ #  # ]:          0 :         aCtx.GetDocId( pDocId );
    3043                 :            : 
    3044                 :            :         sal_uInt8 pSaltData[16];
    3045                 :            :         sal_uInt8 pSaltDigest[16];
    3046         [ #  # ]:          0 :         aCtx.GetEncryptKey( pDocId, pSaltData, pSaltDigest );
    3047                 :            : 
    3048         [ #  # ]:          0 :         pTableStrmTemp->Write( pDocId, 16 );
    3049         [ #  # ]:          0 :         pTableStrmTemp->Write( pSaltData, 16 );
    3050         [ #  # ]:          0 :         pTableStrmTemp->Write( pSaltDigest, 16 );
    3051                 :            : 
    3052 [ #  # ][ #  # ]:          0 :         EncryptRC4(aCtx, GetWriter().Strm(), *pStrmTemp);
    3053                 :            : 
    3054                 :            :         // Write Unencrypted Fib 68 bytes to the start of the workdocument stream
    3055                 :          0 :         pFib->fEncrypted = 1; // fEncrypted indicates the document is encrypted.
    3056                 :          0 :         pFib->fObfuscated = 0; // Must be 0 for RC4.
    3057                 :          0 :         pFib->nHash = 0x34; // encrypt header bytes count of table stream.
    3058                 :          0 :         pFib->nKey = 0; // lkey2 must be 0 for RC4.
    3059                 :            : 
    3060         [ #  # ]:          0 :         pStrmTemp->Seek( 0 );
    3061         [ #  # ]:          0 :         pFib->WriteHeader( *pStrmTemp );
    3062                 :            :     }
    3063                 :            : 
    3064         [ +  + ]:          9 :     if (pUsedNumTbl)           // all used NumRules
    3065                 :            :     {
    3066                 :            :         // clear the part of the list array that was copied from the document
    3067                 :            :         // - it's an auto delete array, so the rest of the array which are
    3068                 :            :         // duplicated lists that were added during the export will be deleted.
    3069 [ +  - ][ +  - ]:          3 :         pUsedNumTbl->erase(pUsedNumTbl->begin(), pUsedNumTbl->begin() + pUsedNumTbl->size() - nUniqueList);
                 [ +  - ]
    3070 [ +  - ][ +  - ]:          3 :         delete pUsedNumTbl;
    3071                 :            :     }
    3072                 :            : 
    3073         [ +  - ]:          9 :     DELETEZ( pGrf );
    3074         [ +  - ]:          9 :     DELETEZ( pMagicTable );
    3075         [ +  - ]:          9 :     DELETEZ( pFldFtn );
    3076         [ +  - ]:          9 :     DELETEZ( pFldTxtBxs );
    3077         [ +  - ]:          9 :     DELETEZ( pFldHFTxtBxs );
    3078         [ +  - ]:          9 :     DELETEZ( pFldAtn );
    3079         [ +  - ]:          9 :     DELETEZ( pFldEdn );
    3080         [ +  - ]:          9 :     DELETEZ( pFldHdFt );
    3081         [ +  - ]:          9 :     DELETEZ( pFldMain );
    3082 [ +  - ][ +  - ]:          9 :     DELETEZ( pStyles );
    3083         [ +  - ]:          9 :     DELETEZ( pO );
    3084 [ +  - ][ +  - ]:          9 :     DELETEZ( pChpPlc );
    3085 [ +  - ][ +  - ]:          9 :     DELETEZ( pPapPlc );
    3086 [ +  - ][ +  - ]:          9 :     DELETEZ( pSepx );
    3087                 :            : 
    3088 [ -  + ][ #  # ]:          9 :     delete pRedlAuthors;
    3089 [ +  - ][ +  - ]:          9 :     delete pSdrObjs;
    3090 [ +  - ][ +  - ]:          9 :     delete pHFSdrObjs;
    3091 [ +  - ][ +  - ]:          9 :     delete pTxtBxs;
    3092 [ +  - ][ +  - ]:          9 :     delete pHFTxtBxs;
    3093 [ +  - ][ +  - ]:          9 :     delete pAtn;
    3094 [ +  - ][ +  - ]:          9 :     delete pEdn;
    3095 [ +  - ][ +  - ]:          9 :     delete pFtn;
    3096         [ +  - ]:          9 :     delete pBkmks;
    3097 [ +  - ][ +  - ]:          9 :     delete pPiece;
    3098                 :          9 :     delete pDop;
    3099                 :          9 :     delete pFib;
    3100         [ +  - ]:          9 :     GetWriter().SetStream( 0 );
    3101                 :            : 
    3102                 :            : 
    3103         [ +  - ]:          9 :     xWwStrm->SetBufferSize( 0 );
    3104         [ +  - ]:          9 :     if( bWrtWW8 )
    3105                 :            :     {
    3106         [ +  - ]:          9 :         xTableStrm->SetBufferSize( 0 );
    3107         [ +  - ]:          9 :         xDataStrm->SetBufferSize( 0 );
    3108 [ +  - ][ +  - ]:          9 :         if( 0 == pDataStrm->Seek( STREAM_SEEK_TO_END ))
    3109                 :            :         {
    3110         [ +  - ]:          9 :             xDataStrm.Clear();
    3111                 :          9 :             pDataStrm = 0;
    3112 [ +  - ][ +  - ]:          9 :             GetWriter().GetStorage().Remove(rtl::OUString(SL::aData));
                 [ +  - ]
    3113                 :            :         }
    3114 [ +  - ][ +  - ]:          9 :     }
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    3115                 :          9 : }
    3116                 :            : 
    3117                 :            : 
    3118                 :          9 : void WW8Export::PrepareStorage()
    3119                 :            : {
    3120                 :            :     sal_uLong nLen;
    3121                 :            :     const sal_uInt8* pData;
    3122                 :            :     const char* pName;
    3123                 :            :     sal_uInt32 nId1;
    3124                 :            : 
    3125         [ +  - ]:          9 :     if (bWrtWW8)
    3126                 :            :     {
    3127                 :            :         static const char aUserName[] = "Microsoft Word-Document";
    3128                 :            :         static const sal_uInt8 aCompObj[] =
    3129                 :            :         {
    3130                 :            :             0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    3131                 :            :             0xFF, 0xFF, 0xFF, 0xFF, 0x06, 0x09, 0x02, 0x00,
    3132                 :            :             0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
    3133                 :            :             0x00, 0x00, 0x00, 0x46, 0x18, 0x00, 0x00, 0x00,
    3134                 :            :             0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    3135                 :            :             0x74, 0x20, 0x57, 0x6F, 0x72, 0x64, 0x2D, 0x44,
    3136                 :            :             0x6F, 0x6B, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x00,
    3137                 :            :             0x0A, 0x00, 0x00, 0x00, 0x4D, 0x53, 0x57, 0x6F,
    3138                 :            :             0x72, 0x64, 0x44, 0x6F, 0x63, 0x00, 0x10, 0x00,
    3139                 :            :             0x00, 0x00, 0x57, 0x6F, 0x72, 0x64, 0x2E, 0x44,
    3140                 :            :             0x6F, 0x63, 0x75, 0x6D, 0x65, 0x6E, 0x74, 0x2E,
    3141                 :            :             0x38, 0x00, 0xF4, 0x39, 0xB2, 0x71, 0x00, 0x00,
    3142                 :            :             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    3143                 :            :             0x00, 0x00
    3144                 :            :         };
    3145                 :            : 
    3146                 :          9 :         pName = aUserName;
    3147                 :          9 :         pData = aCompObj;
    3148                 :          9 :         nLen = sizeof( aCompObj );
    3149                 :          9 :         nId1 = 0x00020906L;
    3150                 :            :     }
    3151                 :            :     else
    3152                 :            :     {
    3153                 :            :         static const char aUserName[] = "Microsoft Word 6.0 Document";
    3154                 :            :         static const sal_uInt8 aCompObj[] =
    3155                 :            :         {
    3156                 :            :             0x01, 0x00, 0xFE, 0xFF, 0x03, 0x0A, 0x00, 0x00,
    3157                 :            :             0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x09, 0x02, 0x00,
    3158                 :            :             0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00,
    3159                 :            :             0x00, 0x00, 0x00, 0x46, 0x1C, 0x00, 0x00, 0x00,
    3160                 :            :             0x4D, 0x69, 0x63, 0x72, 0x6F, 0x73, 0x6F, 0x66,
    3161                 :            :             0x74, 0x20, 0x57, 0x6F, 0x72, 0x64, 0x20, 0x36,
    3162                 :            :             0x2E, 0x30, 0x2D, 0x44, 0x6F, 0x6B, 0x75, 0x6D,
    3163                 :            :             0x65, 0x6E, 0x74, 0x00, 0x0A, 0x00, 0x00, 0x00,
    3164                 :            :             0x4D, 0x53, 0x57, 0x6F, 0x72, 0x64, 0x44, 0x6F,
    3165                 :            :             0x63, 0x00, 0x10, 0x00, 0x00, 0x00, 0x57, 0x6F,
    3166                 :            :             0x72, 0x64, 0x2E, 0x44, 0x6F, 0x63, 0x75, 0x6D,
    3167                 :            :             0x65, 0x6E, 0x74, 0x2E, 0x36, 0x00, 0x00, 0x00,
    3168                 :            :             0x00, 0x00
    3169                 :            :         };
    3170                 :            : 
    3171                 :          0 :         pName = aUserName;
    3172                 :          0 :         pData = aCompObj;
    3173                 :          0 :         nLen = sizeof( aCompObj );
    3174                 :          0 :         nId1 = 0x00020900L;
    3175                 :            :     }
    3176                 :            : 
    3177                 :            :     SvGlobalName aGName( nId1, 0x0000, 0x0000, 0xc0, 0x00, 0x00, 0x00,
    3178         [ +  - ]:          9 :                          0x00, 0x00, 0x00, 0x46 );
    3179 [ +  - ][ +  - ]:          9 :     GetWriter().GetStorage().SetClass( aGName, 0, rtl::OUString::createFromAscii( pName ));
                 [ +  - ]
    3180 [ +  - ][ +  - ]:          9 :     SvStorageStreamRef xStor( GetWriter().GetStorage().OpenSotStream(sCompObj) );
                 [ +  - ]
    3181         [ +  - ]:          9 :     xStor->Write( pData, nLen );
    3182                 :            : 
    3183                 :          9 :     SwDocShell* pDocShell = pDoc->GetDocShell ();
    3184                 :            :     OSL_ENSURE(pDocShell, "no SwDocShell");
    3185                 :            : 
    3186         [ +  - ]:          9 :     if (pDocShell) {
    3187                 :            :         uno::Reference<document::XDocumentPropertiesSupplier> xDPS(
    3188 [ +  - ][ +  - ]:          9 :             pDocShell->GetModel(), uno::UNO_QUERY_THROW);
    3189                 :            :         uno::Reference<document::XDocumentProperties> xDocProps(
    3190 [ +  - ][ +  - ]:          9 :             xDPS->getDocumentProperties());
    3191                 :            :         OSL_ENSURE(xDocProps.is(), "DocumentProperties is null");
    3192                 :            : 
    3193         [ +  - ]:          9 :         if (xDocProps.is())
    3194                 :            :         {
    3195 [ +  - ][ +  - ]:          9 :             if ( SvtFilterOptions::Get().IsEnableWordPreview() )
                 [ -  + ]
    3196                 :            :             {
    3197                 :            :                 ::boost::shared_ptr<GDIMetaFile> pMetaFile =
    3198         [ #  # ]:          0 :                     pDocShell->GetPreviewMetaFile (sal_False);
    3199                 :            :                 uno::Sequence<sal_uInt8> metaFile(
    3200         [ #  # ]:          0 :                     sfx2::convertMetaFile(pMetaFile.get()));
    3201 [ #  # ][ #  # ]:          0 :                 sfx2::SaveOlePropertySet(xDocProps, &GetWriter().GetStorage(), &metaFile);
                 [ #  # ]
    3202                 :            :             }
    3203                 :            :             else
    3204         [ +  - ]:          9 :                 sfx2::SaveOlePropertySet( xDocProps, &GetWriter().GetStorage() );
    3205                 :          9 :         }
    3206 [ +  - ][ +  - ]:          9 :     }
    3207                 :          9 : }
    3208                 :            : 
    3209                 :          9 : sal_uLong SwWW8Writer::WriteStorage()
    3210                 :            : {
    3211                 :            :     // #i34818# - update layout (if present), for SwWriteTable
    3212                 :          9 :     ViewShell* pViewShell = NULL;
    3213         [ +  - ]:          9 :     pDoc->GetEditShell( &pViewShell );
    3214         [ +  - ]:          9 :     if( pViewShell != NULL )
    3215         [ +  - ]:          9 :         pViewShell->CalcLayout();
    3216                 :            : 
    3217         [ +  - ]:          9 :     long nMaxNode = pDoc->GetNodes().Count();
    3218         [ +  - ]:          9 :     ::StartProgress( STR_STATSTR_W4WWRITE, 0, nMaxNode, pDoc->GetDocShell() );
    3219                 :            : 
    3220                 :            :     // Tabelle am Doc.-Anfang beachten
    3221                 :            :     {
    3222         [ +  - ]:          9 :         SwTableNode * pTNd = pCurPam->GetNode()->FindTableNode();
    3223 [ -  + ][ #  # ]:          9 :         if( pTNd && bWriteAll )
    3224                 :            :             // mit dem TabellenNode anfangen !!
    3225         [ #  # ]:          0 :             pCurPam->GetPoint()->nNode = *pTNd;
    3226                 :            :     }
    3227                 :            : 
    3228                 :            :     // Do the actual export
    3229                 :            :     {
    3230         [ +  - ]:          9 :         WW8Export aExport( this, pDoc, pCurPam, pOrigPam, m_bWrtWW8 );
    3231                 :          9 :         m_pExport = &aExport;
    3232         [ +  - ]:          9 :         aExport.ExportDocument( bWriteAll );
    3233         [ +  - ]:          9 :         m_pExport = NULL;
    3234                 :            :     }
    3235                 :            : 
    3236         [ +  - ]:          9 :     ::EndProgress( pDoc->GetDocShell() );
    3237                 :          9 :     return 0;
    3238                 :            : }
    3239                 :            : 
    3240                 :          0 : sal_uLong SwWW8Writer::WriteMedium( SfxMedium& )
    3241                 :            : {
    3242                 :          0 :     return WriteStorage();
    3243                 :            : }
    3244                 :            : 
    3245                 :          9 : sal_uLong SwWW8Writer::Write( SwPaM& rPaM, SfxMedium& rMed,
    3246                 :            :                           const String* pFileName )
    3247                 :            : {
    3248                 :          9 :     mpMedium = &rMed;
    3249                 :          9 :     sal_uLong nRet = StgWriter::Write( rPaM, rMed, pFileName );
    3250                 :          9 :     mpMedium = NULL;
    3251                 :          9 :     return nRet;
    3252                 :            : }
    3253                 :            : 
    3254                 :        144 : MSWordExportBase::MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam )
    3255                 :            :     : aMainStg(sMainStream), pISet(0), pUsedNumTbl(0), mpTopNodeOfHdFtPage(0),
    3256                 :            :     pBmpPal(0), pOLEExp(0), pOCXExp(0),
    3257                 :          0 :     mpTableInfo(new ww8::WW8TableInfo()), nUniqueList(0),
    3258                 :            :     mnHdFtIndex(0), pAktPageDesc(0), pPapPlc(0), pChpPlc(0), pChpIter(0),
    3259                 :            :     pStyles( NULL ),
    3260                 :            :     bHasHdr(false), bHasFtr(false), bSubstituteBullets(true),
    3261                 :            :     mbExportModeRTF( false ),
    3262                 :            :     mbOutOutlineOnly( false ),
    3263                 :            :     pDoc( pDocument ),
    3264                 :            :     pCurPam( pCurrentPam ),
    3265 [ +  - ][ +  - ]:        144 :     pOrigPam( pOriginalPam )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    3266                 :            : {
    3267                 :        144 : }
    3268                 :            : 
    3269 [ +  - ][ +  - ]:        144 : MSWordExportBase::~MSWordExportBase()
                 [ +  - ]
    3270                 :            : {
    3271         [ +  + ]:        144 :     delete pBmpPal;
    3272                 :        144 :     delete pOLEExp;
    3273 [ +  - ][ +  - ]:        144 :     delete pOCXExp;
    3274         [ -  + ]:        144 : }
    3275                 :            : 
    3276                 :          9 : WW8Export::WW8Export( SwWW8Writer *pWriter,
    3277                 :            :         SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam,
    3278                 :            :         bool bIsWW8 )
    3279                 :            :     : MSWordExportBase( pDocument, pCurrentPam, pOriginalPam ),
    3280                 :            :       pO( NULL ),
    3281                 :            :       pSepx( NULL ),
    3282                 :            :       bWrtWW8( bIsWW8 ),
    3283                 :            :       m_pWriter( pWriter ),
    3284         [ +  - ]:          9 :       m_pAttrOutput( new WW8AttributeOutput( *this ) )
    3285                 :            : {
    3286                 :          9 : }
    3287                 :            : 
    3288                 :          9 : WW8Export::~WW8Export()
    3289                 :            : {
    3290 [ +  - ][ +  - ]:          9 :     delete m_pAttrOutput, m_pAttrOutput = NULL;
    3291         [ -  + ]:          9 : }
    3292                 :            : 
    3293                 :       3420 : AttributeOutputBase& WW8Export::AttrOutput() const
    3294                 :            : {
    3295                 :       3420 :     return *m_pAttrOutput;
    3296                 :            : }
    3297                 :            : 
    3298                 :          0 : MSWordSections& WW8Export::Sections() const
    3299                 :            : {
    3300                 :          0 :     return *pSepx;
    3301                 :            : }
    3302                 :            : 
    3303                 :          9 : SwWW8Writer::SwWW8Writer(const String& rFltName, const String& rBaseURL)
    3304                 :            :     : StgWriter(),
    3305         [ +  - ]:          9 :       m_bWrtWW8( rFltName.EqualsAscii( FILTER_WW8 ) ),
    3306                 :            :       m_pExport( NULL ),
    3307                 :          9 :       mpMedium( 0 )
    3308                 :            : {
    3309         [ +  - ]:          9 :     SetBaseURL( rBaseURL );
    3310                 :          9 : }
    3311                 :            : 
    3312                 :          9 : SwWW8Writer::~SwWW8Writer()
    3313                 :            : {
    3314         [ -  + ]:         18 : }
    3315                 :            : 
    3316                 :          0 : extern "C" SAL_DLLPUBLIC_EXPORT sal_uLong SAL_CALL SaveOrDelMSVBAStorage_ww8( SfxObjectShell& rDoc, SotStorage& rStor, sal_Bool bSaveInto, const String& rStorageName )
    3317                 :            : {
    3318         [ #  # ]:          0 :     SvxImportMSVBasic aTmp( rDoc, rStor );
    3319 [ #  # ][ #  # ]:          0 :     return aTmp.SaveOrDelMSVBAStorage( bSaveInto, rStorageName );
    3320                 :            : }
    3321                 :            : 
    3322                 :          9 : extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL ExportDOC( const String& rFltName, const String& rBaseURL, WriterRef& xRet )
    3323                 :            : {
    3324         [ +  - ]:          9 :     xRet = new SwWW8Writer( rFltName, rBaseURL );
    3325                 :          9 : }
    3326                 :            : 
    3327                 :            : 
    3328                 :          0 : extern "C" SAL_DLLPUBLIC_EXPORT sal_uLong SAL_CALL GetSaveWarningOfMSVBAStorage_ww8(  SfxObjectShell &rDocS )
    3329                 :            : {
    3330                 :          0 :     return SvxImportMSVBasic::GetSaveWarningOfMSVBAStorage( rDocS );
    3331                 :            : }
    3332                 :            : 
    3333                 :         18 : bool WW8_WrPlcFtnEdn::WriteTxt( WW8Export& rWrt )
    3334                 :            : {
    3335                 :         18 :     bool bRet = false;
    3336         [ +  + ]:         18 :     if (TXT_FTN == nTyp)
    3337                 :            :     {
    3338                 :          9 :         bRet = WriteGenericTxt( rWrt, TXT_FTN, rWrt.pFib->ccpFtn );
    3339                 :          9 :         rWrt.pFldFtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
    3340                 :          9 :                             rWrt.pFib->ccpText );
    3341                 :            :     }
    3342                 :            :     else
    3343                 :            :     {
    3344                 :          9 :         bRet = WriteGenericTxt( rWrt, TXT_EDN, rWrt.pFib->ccpEdn );
    3345                 :          9 :         rWrt.pFldEdn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
    3346                 :            :                             rWrt.pFib->ccpText + rWrt.pFib->ccpFtn
    3347                 :          9 :                             + rWrt.pFib->ccpHdr + rWrt.pFib->ccpAtn );
    3348                 :            :     }
    3349                 :         18 :     return bRet;
    3350                 :            : }
    3351                 :            : 
    3352                 :         18 : void WW8_WrPlcFtnEdn::WritePlc( WW8Export& rWrt ) const
    3353                 :            : {
    3354         [ +  + ]:         18 :     if( TXT_FTN == nTyp )
    3355                 :            :     {
    3356                 :            :         WriteGenericPlc( rWrt, TXT_FTN, rWrt.pFib->fcPlcffndTxt,
    3357                 :            :             rWrt.pFib->lcbPlcffndTxt, rWrt.pFib->fcPlcffndRef,
    3358                 :          9 :             rWrt.pFib->lcbPlcffndRef );
    3359                 :            :     }
    3360                 :            :     else
    3361                 :            :     {
    3362                 :            :         WriteGenericPlc( rWrt, TXT_EDN, rWrt.pFib->fcPlcfendTxt,
    3363                 :            :             rWrt.pFib->lcbPlcfendTxt, rWrt.pFib->fcPlcfendRef,
    3364                 :          9 :             rWrt.pFib->lcbPlcfendRef );
    3365                 :            :     }
    3366                 :         18 : }
    3367                 :            : 
    3368                 :            : 
    3369                 :          9 : bool WW8_WrPlcAnnotations::WriteTxt( WW8Export& rWrt )
    3370                 :            : {
    3371                 :          9 :     bool bRet = WriteGenericTxt( rWrt, TXT_ATN, rWrt.pFib->ccpAtn );
    3372                 :          9 :     rWrt.pFldAtn->Finish( rWrt.Fc2Cp( rWrt.Strm().Tell() ),
    3373                 :            :                         rWrt.pFib->ccpText + rWrt.pFib->ccpFtn
    3374                 :          9 :                         + rWrt.pFib->ccpHdr );
    3375                 :          9 :     return bRet;
    3376                 :            : }
    3377                 :            : 
    3378                 :          9 : void WW8_WrPlcAnnotations::WritePlc( WW8Export& rWrt ) const
    3379                 :            : {
    3380                 :            :     WriteGenericPlc( rWrt, TXT_ATN, rWrt.pFib->fcPlcfandTxt,
    3381                 :            :         rWrt.pFib->lcbPlcfandTxt, rWrt.pFib->fcPlcfandRef,
    3382                 :          9 :         rWrt.pFib->lcbPlcfandRef );
    3383                 :          9 : }
    3384                 :            : 
    3385                 :         18 : void WW8_WrPlcTxtBoxes::WritePlc( WW8Export& rWrt ) const
    3386                 :            : {
    3387         [ +  + ]:         18 :     if( TXT_TXTBOX == nTyp )
    3388                 :            :     {
    3389                 :            :         WriteGenericPlc( rWrt, nTyp, rWrt.pFib->fcPlcftxbxBkd,
    3390                 :            :             rWrt.pFib->lcbPlcftxbxBkd, rWrt.pFib->fcPlcftxbxTxt,
    3391                 :          9 :             rWrt.pFib->lcbPlcftxbxTxt );
    3392                 :            :     }
    3393                 :            :     else
    3394                 :            :     {
    3395                 :            :         WriteGenericPlc( rWrt, nTyp, rWrt.pFib->fcPlcfHdrtxbxBkd,
    3396                 :            :             rWrt.pFib->lcbPlcfHdrtxbxBkd, rWrt.pFib->fcPlcfHdrtxbxTxt,
    3397                 :          9 :             rWrt.pFib->lcbPlcfHdrtxbxTxt );
    3398                 :            :     }
    3399                 :         18 : }
    3400                 :            : 
    3401                 :          9 : void WW8Export::RestoreMacroCmds()
    3402                 :            : {
    3403                 :          9 :     pFib->fcCmds = pTableStrm->Tell();
    3404                 :            : 
    3405         [ +  - ]:          9 :     uno::Reference < embed::XStorage > xSrcRoot(pDoc->GetDocShell()->GetStorage());
    3406                 :            :     try
    3407                 :            :     {
    3408                 :            :         uno::Reference < io::XStream > xSrcStream =
    3409 [ +  - ][ +  + ]:          9 :                 xSrcRoot->openStreamElement( rtl::OUString(SL::aMSMacroCmds), embed::ElementModes::READ );
    3410         [ +  - ]:          3 :         SvStream* pStream = ::utl::UcbStreamHelper::CreateStream( xSrcStream );
    3411                 :            : 
    3412 [ +  - ][ +  - ]:          3 :         if ( pStream && SVSTREAM_OK == pStream->GetError())
                 [ +  - ]
    3413                 :            :         {
    3414         [ +  - ]:          3 :             pStream->Seek(STREAM_SEEK_TO_END);
    3415                 :          3 :             pFib->lcbCmds = pStream->Tell();
    3416         [ +  - ]:          3 :             pStream->Seek(0);
    3417                 :            : 
    3418         [ +  - ]:          3 :             sal_uInt8 *pBuffer = new sal_uInt8[pFib->lcbCmds];
    3419         [ +  - ]:          3 :             bool bReadOk = checkRead(*pStream, pBuffer, pFib->lcbCmds);
    3420         [ +  - ]:          3 :             if (bReadOk)
    3421         [ +  - ]:          3 :                 pTableStrm->Write(pBuffer, pFib->lcbCmds);
    3422         [ +  - ]:          3 :             delete[] pBuffer;
    3423                 :            : 
    3424                 :            :         }
    3425                 :            : 
    3426 [ +  - ][ +  - ]:          9 :         delete pStream;
                 [ -  + ]
    3427                 :            :     }
    3428         [ +  - ]:          6 :     catch ( const uno::Exception& )
    3429                 :            :     {
    3430                 :            :     }
    3431                 :            : 
    3432                 :            :     // set len to FIB
    3433                 :          9 :     pFib->lcbCmds = pTableStrm->Tell() - pFib->fcCmds;
    3434                 :          9 : }
    3435                 :            : 
    3436                 :          0 : void WW8SHDLong::Write( WW8Export& rExport )
    3437                 :            : {
    3438                 :          0 :     rExport.InsUInt32( m_cvFore );
    3439                 :          0 :     rExport.InsUInt32( m_cvBack );
    3440                 :          0 :     rExport.InsUInt16( m_ipat );
    3441                 :          0 : }
    3442                 :            : 
    3443                 :          0 : void WW8Export::WriteFormData( const ::sw::mark::IFieldmark& rFieldmark )
    3444                 :            : {
    3445                 :            :     OSL_ENSURE( bWrtWW8, "No 95 export yet" );
    3446         [ #  # ]:          0 :     if ( !bWrtWW8 )
    3447                 :            :         return;
    3448                 :            : 
    3449                 :          0 :     const ::sw::mark::IFieldmark* pFieldmark = &rFieldmark;
    3450         [ #  # ]:          0 :     const ::sw::mark::ICheckboxFieldmark* pAsCheckbox = dynamic_cast< const ::sw::mark::ICheckboxFieldmark* >( pFieldmark );
    3451                 :            : 
    3452                 :            : 
    3453                 :            :     OSL_ENSURE(rFieldmark.GetFieldname() == ODF_FORMTEXT ||
    3454                 :            :                 rFieldmark.GetFieldname() == ODF_FORMDROPDOWN ||
    3455                 :            :                 rFieldmark.GetFieldname() == ODF_FORMCHECKBOX, "Unknown field type!!!");
    3456 [ #  # ][ #  # ]:          0 :     if ( ! ( rFieldmark.GetFieldname() == ODF_FORMTEXT ||
           [ #  #  #  # ]
    3457 [ #  # ][ #  # ]:          0 :                 rFieldmark.GetFieldname() == ODF_FORMDROPDOWN ||
                 [ #  # ]
    3458 [ #  # ][ #  # ]:          0 :                 rFieldmark.GetFieldname() == ODF_FORMCHECKBOX ) )
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    3459                 :            :         return;
    3460                 :            : 
    3461                 :          0 :     int type = 0; // TextFieldmark
    3462         [ #  # ]:          0 :     if ( pAsCheckbox )
    3463                 :          0 :         type = 1;
    3464 [ #  # ][ #  # ]:          0 :     if ( rFieldmark.GetFieldname() == ODF_FORMDROPDOWN )
    3465                 :          0 :         type=2;
    3466                 :            : 
    3467 [ #  # ][ #  # ]:          0 :     ::sw::mark::IFieldmark::parameter_map_t::const_iterator pNameParameter = rFieldmark.GetParameters()->find("name");
    3468                 :          0 :     ::rtl::OUString ffname;
    3469 [ #  # ][ #  # ]:          0 :     if(pNameParameter != rFieldmark.GetParameters()->end())
    3470                 :          0 :         pNameParameter->second >>= ffname;
    3471                 :            : 
    3472                 :          0 :     sal_uLong nDataStt = pDataStrm->Tell();
    3473 [ #  # ][ #  # ]:          0 :     pChpPlc->AppendFkpEntry(Strm().Tell());
    3474                 :            : 
    3475         [ #  # ]:          0 :     WriteChar(0x01);
    3476                 :            :     static sal_uInt8 aArr1[] =
    3477                 :            :     {
    3478                 :            :         0x03, 0x6a, 0,0,0,0,    // sprmCPicLocation
    3479                 :            : 
    3480                 :            :         0x06, 0x08, 0x01,       // sprmCFData
    3481                 :            :         0x55, 0x08, 0x01,       // sprmCFSpec
    3482                 :            :         0x02, 0x08, 0x01        // sprmCFFldVanish
    3483                 :            :     };
    3484                 :          0 :     sal_uInt8* pDataAdr = aArr1 + 2;
    3485                 :          0 :     Set_UInt32(pDataAdr, nDataStt);
    3486                 :            : 
    3487 [ #  # ][ #  # ]:          0 :     pChpPlc->AppendFkpEntry( Strm().Tell(), sizeof( aArr1 ), aArr1 );
    3488                 :            : 
    3489                 :            :     struct FFDataHeader
    3490                 :            :     {
    3491                 :            :         sal_uInt32 version;
    3492                 :            :         sal_uInt16 bits;
    3493                 :            :         sal_uInt16 cch;
    3494                 :            :         sal_uInt16 hps;
    3495                 :          0 :         FFDataHeader() : version( 0xFFFFFFFF ), bits(0), cch(0), hps(0) {}
    3496                 :            :     };
    3497                 :            : 
    3498                 :            : 
    3499                 :          0 :     FFDataHeader aFldHeader;
    3500                 :          0 :     aFldHeader.bits |= (type & 0x03);
    3501                 :            : 
    3502                 :          0 :     sal_Int32 ffres = 0; // rFieldmark.GetFFRes();
    3503 [ #  # ][ #  # ]:          0 :     if ( pAsCheckbox && pAsCheckbox->IsChecked() )
         [ #  # ][ #  # ]
    3504                 :          0 :         ffres = 1;
    3505         [ #  # ]:          0 :     else if ( type == 2 )
    3506                 :            :     {
    3507 [ #  # ][ #  # ]:          0 :         ::sw::mark::IFieldmark::parameter_map_t::const_iterator pResParameter = rFieldmark.GetParameters()->find(ODF_FORMDROPDOWN_RESULT);
    3508 [ #  # ][ #  # ]:          0 :         if(pResParameter != rFieldmark.GetParameters()->end())
    3509                 :          0 :             pResParameter->second >>= ffres;
    3510                 :            :         else
    3511                 :          0 :             ffres = 0;
    3512                 :            :     }
    3513                 :          0 :     aFldHeader.bits |= ( (ffres<<2) & 0x7C );
    3514                 :            : 
    3515         [ #  # ]:          0 :     std::vector< ::rtl::OUString > aListItems;
    3516         [ #  # ]:          0 :     if (type==2)
    3517                 :            :     {
    3518                 :          0 :         aFldHeader.bits |= 0x8000; // ffhaslistbox
    3519         [ #  # ]:          0 :         const ::sw::mark::IFieldmark::parameter_map_t* const pParameters = rFieldmark.GetParameters();
    3520         [ #  # ]:          0 :         ::sw::mark::IFieldmark::parameter_map_t::const_iterator pListEntries = pParameters->find(ODF_FORMDROPDOWN_LISTENTRY);
    3521         [ #  # ]:          0 :         if(pListEntries != pParameters->end())
    3522                 :            :         {
    3523         [ #  # ]:          0 :             uno::Sequence< ::rtl::OUString > vListEntries;
    3524         [ #  # ]:          0 :             pListEntries->second >>= vListEntries;
    3525 [ #  # ][ #  # ]:          0 :             copy(::comphelper::stl_begin(vListEntries), ::comphelper::stl_end(vListEntries), back_inserter(aListItems));
         [ #  # ][ #  # ]
                 [ #  # ]
    3526                 :            :         }
    3527                 :            :     }
    3528                 :            : 
    3529                 :          0 :     const ::rtl::OUString ffdeftext;
    3530                 :          0 :     const ::rtl::OUString ffformat;
    3531                 :          0 :     const ::rtl::OUString ffhelptext;
    3532                 :          0 :     const ::rtl::OUString ffstattext;
    3533                 :          0 :     const ::rtl::OUString ffentrymcr;
    3534                 :          0 :     const ::rtl::OUString ffexitmcr;
    3535                 :            : 
    3536                 :            : 
    3537                 :            :     const sal_uInt8 aFldData[] =
    3538                 :            :     {
    3539                 :            :         0x44,0,         // the start of "next" data
    3540                 :            :         0,0,0,0,0,0,0,0,0,0,                // PIC-Structure!  /10
    3541                 :            :         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    //  |              /16
    3542                 :            :         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    //  |              /16
    3543                 :            :         0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,    //  |              /16
    3544                 :            :         0,0,0,0,                            // /               /4
    3545                 :          0 :     };
    3546                 :            :    sal_uInt32 slen = sizeof(sal_uInt32)
    3547                 :            :         + sizeof(aFldData)
    3548                 :            :         + sizeof( aFldHeader.version ) + sizeof( aFldHeader.bits ) + sizeof( aFldHeader.cch ) + sizeof( aFldHeader.hps )
    3549                 :          0 :         + 2*ffname.getLength() + 4
    3550                 :          0 :         + 2*ffformat.getLength() + 4
    3551                 :          0 :         + 2*ffhelptext.getLength() + 4
    3552                 :          0 :         + 2*ffstattext.getLength() + 4
    3553                 :          0 :         + 2*ffentrymcr.getLength() + 4
    3554                 :          0 :         + 2*ffexitmcr.getLength() + 4;
    3555         [ #  # ]:          0 :     if ( type )
    3556                 :          0 :         slen += 2; // wDef
    3557                 :            :     else
    3558                 :          0 :         slen += 2*ffdeftext.getLength() + 4; //xstzTextDef
    3559         [ #  # ]:          0 :     if ( type==2 ) {
    3560                 :          0 :         slen += 2; // sttb ( fExtend )
    3561                 :          0 :         slen += 4; // for num of list items
    3562                 :          0 :         const int items = aListItems.size();
    3563         [ #  # ]:          0 :         for( int i = 0; i < items; i++ ) {
    3564                 :          0 :             rtl::OUString item = aListItems[i];
    3565                 :          0 :             slen += 2 * item.getLength() + 2;
    3566                 :          0 :         }
    3567                 :            :     }
    3568                 :            : 
    3569         [ #  # ]:          0 :     *pDataStrm << slen;
    3570                 :            : 
    3571                 :          0 :     int len = sizeof( aFldData );
    3572                 :            :     OSL_ENSURE( len == 0x44-sizeof(sal_uInt32), "SwWW8Writer::WriteFormData(..) - wrong aFldData length" );
    3573         [ #  # ]:          0 :     pDataStrm->Write( aFldData, len );
    3574                 :            : 
    3575 [ #  # ][ #  # ]:          0 :     *pDataStrm << aFldHeader.version << aFldHeader.bits << aFldHeader.cch << aFldHeader.hps;
         [ #  # ][ #  # ]
    3576                 :            : 
    3577 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, ffname, true ); // Form field name
                 [ #  # ]
    3578                 :            : 
    3579         [ #  # ]:          0 :     if ( !type )
    3580 [ #  # ][ #  # ]:          0 :         SwWW8Writer::WriteString_xstz( *pDataStrm, ffdeftext, true );
                 [ #  # ]
    3581         [ #  # ]:          0 :     if ( type )
    3582         [ #  # ]:          0 :         *pDataStrm << sal_uInt16(0);
    3583                 :            : 
    3584                 :            : 
    3585 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffformat ), true );
                 [ #  # ]
    3586 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffhelptext ), true );
                 [ #  # ]
    3587 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffstattext ), true );
                 [ #  # ]
    3588 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffentrymcr ), true );
                 [ #  # ]
    3589 [ #  # ][ #  # ]:          0 :     SwWW8Writer::WriteString_xstz( *pDataStrm, String( ffexitmcr ), true );
                 [ #  # ]
    3590         [ #  # ]:          0 :     if (type==2) {
    3591         [ #  # ]:          0 :         *pDataStrm<<(sal_uInt16)0xFFFF;
    3592                 :          0 :         const int items=aListItems.size();
    3593         [ #  # ]:          0 :         *pDataStrm<<(sal_uInt32)items;
    3594         [ #  # ]:          0 :         for(int i=0;i<items;i++) {
    3595                 :          0 :             rtl::OUString item=aListItems[i];
    3596 [ #  # ][ #  # ]:          0 :             SwWW8Writer::WriteString_xstz( *pDataStrm, item, false );
                 [ #  # ]
    3597                 :          0 :         }
    3598                 :          0 :     }
    3599                 :            : }
    3600                 :            : 
    3601                 :          0 : void WW8Export::WriteHyperlinkData( const sw::mark::IFieldmark& /*rFieldmark*/ )
    3602                 :            : {
    3603                 :            :     //@TODO implement me !!!
    3604                 :          0 : }
    3605                 :            : 
    3606                 :          0 : void WW8AttributeOutput::TableNodeInfoInner( ww8::WW8TableNodeInfoInner::Pointer_t pNodeInfoInner )
    3607                 :            : {
    3608                 :            :     SVBT16 nStyle;
    3609                 :          0 :     ShortToSVBT16( m_rWW8Export.nStyleBeforeFly, nStyle );
    3610                 :            : 
    3611                 :            : #ifdef DBG_UTIL
    3612                 :            :     ::std::clog << "<OutWW8_TableNodeInfoInner>" << pNodeInfoInner->toString();
    3613                 :            : #endif
    3614                 :            : 
    3615                 :          0 :     m_rWW8Export.pO->clear();
    3616                 :            : 
    3617         [ #  # ]:          0 :     sal_uInt32 nShadowsBefore = pNodeInfoInner->getShadowsBefore();
    3618         [ #  # ]:          0 :     if (nShadowsBefore > 0)
    3619                 :            :     {
    3620                 :            :         ww8::WW8TableNodeInfoInner::Pointer_t
    3621 [ #  # ][ #  # ]:          0 :             pTmpNodeInfoInner(new ww8::WW8TableNodeInfoInner(NULL));
                 [ #  # ]
    3622                 :            : 
    3623 [ #  # ][ #  # ]:          0 :         pTmpNodeInfoInner->setDepth(pNodeInfoInner->getDepth());
    3624         [ #  # ]:          0 :         pTmpNodeInfoInner->setEndOfCell(true);
    3625                 :            : 
    3626         [ #  # ]:          0 :         for (sal_uInt32 n = 0; n < nShadowsBefore; ++n)
    3627                 :            :         {
    3628 [ #  # ][ #  # ]:          0 :             m_rWW8Export.WriteCR(pTmpNodeInfoInner);
                 [ #  # ]
    3629                 :            : 
    3630         [ #  # ]:          0 :             m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nStyle, (sal_uInt8*)&nStyle+2 );     // Style #
    3631 [ #  # ][ #  # ]:          0 :             TableInfoCell(pTmpNodeInfoInner);
                 [ #  # ]
    3632                 :            :             m_rWW8Export.pPapPlc->AppendFkpEntry
    3633 [ #  # ][ #  # ]:          0 :                 ( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
                 [ #  # ]
    3634                 :            : 
    3635                 :          0 :             m_rWW8Export.pO->clear();
    3636         [ #  # ]:          0 :         }
    3637                 :            :     }
    3638                 :            : 
    3639 [ #  # ][ #  # ]:          0 :     if (pNodeInfoInner->isEndOfCell())
    3640                 :            :     {
    3641                 :            : #ifdef DBG_UTIL
    3642                 :            :         ::std::clog << "<endOfCell/>" << ::std::endl;
    3643                 :            : #endif
    3644 [ #  # ][ #  # ]:          0 :         m_rWW8Export.WriteCR(pNodeInfoInner);
                 [ #  # ]
    3645                 :            : 
    3646         [ #  # ]:          0 :         m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nStyle, (sal_uInt8*)&nStyle+2 );     // Style #
    3647 [ #  # ][ #  # ]:          0 :         TableInfoCell(pNodeInfoInner);
                 [ #  # ]
    3648 [ #  # ][ #  # ]:          0 :         m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
                 [ #  # ]
    3649                 :            : 
    3650                 :          0 :         m_rWW8Export.pO->clear();
    3651                 :            :     }
    3652                 :            : 
    3653         [ #  # ]:          0 :     sal_uInt32 nShadowsAfter = pNodeInfoInner->getShadowsAfter();
    3654         [ #  # ]:          0 :     if (nShadowsAfter > 0)
    3655                 :            :     {
    3656                 :            :         ww8::WW8TableNodeInfoInner::Pointer_t
    3657 [ #  # ][ #  # ]:          0 :             pTmpNodeInfoInner(new ww8::WW8TableNodeInfoInner(NULL));
                 [ #  # ]
    3658                 :            : 
    3659 [ #  # ][ #  # ]:          0 :         pTmpNodeInfoInner->setDepth(pNodeInfoInner->getDepth());
    3660         [ #  # ]:          0 :         pTmpNodeInfoInner->setEndOfCell(true);
    3661                 :            : 
    3662         [ #  # ]:          0 :         for (sal_uInt32 n = 0; n < nShadowsAfter; ++n)
    3663                 :            :         {
    3664 [ #  # ][ #  # ]:          0 :             m_rWW8Export.WriteCR(pTmpNodeInfoInner);
                 [ #  # ]
    3665                 :            : 
    3666         [ #  # ]:          0 :             m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nStyle, (sal_uInt8*)&nStyle+2 );     // Style #
    3667 [ #  # ][ #  # ]:          0 :             TableInfoCell(pTmpNodeInfoInner);
                 [ #  # ]
    3668 [ #  # ][ #  # ]:          0 :             m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
                 [ #  # ]
    3669                 :            : 
    3670                 :          0 :             m_rWW8Export.pO->clear();
    3671         [ #  # ]:          0 :         }
    3672                 :            :     }
    3673                 :            : 
    3674 [ #  # ][ #  # ]:          0 :     if (pNodeInfoInner->isEndOfLine())
    3675                 :            :     {
    3676                 :            : #ifdef DBG_UTIL
    3677                 :            :         ::std::clog << "<endOfLine/>" << ::std::endl;
    3678                 :            : #endif
    3679 [ #  # ][ #  # ]:          0 :         TableRowEnd(pNodeInfoInner->getDepth());
    3680                 :            : 
    3681                 :          0 :         ShortToSVBT16(0, nStyle);
    3682         [ #  # ]:          0 :         m_rWW8Export.pO->insert( m_rWW8Export.pO->end(), (sal_uInt8*)&nStyle, (sal_uInt8*)&nStyle+2 );     // Style #
    3683 [ #  # ][ #  # ]:          0 :         TableInfoRow(pNodeInfoInner);
                 [ #  # ]
    3684 [ #  # ][ #  # ]:          0 :         m_rWW8Export.pPapPlc->AppendFkpEntry( m_rWW8Export.Strm().Tell(), m_rWW8Export.pO->size(), m_rWW8Export.pO->data() );
                 [ #  # ]
    3685                 :            : 
    3686                 :          0 :         m_rWW8Export.pO->clear();
    3687                 :            :     }
    3688                 :            : #ifdef DBG_UTIL
    3689                 :            :     ::std::clog << "</OutWW8_TableNodeInfoInner>" << ::std::endl;
    3690                 :            : #endif
    3691                 :          0 : }
    3692                 :            : 
    3693                 :        144 : void MSWordExportBase::OutputStartNode( const SwStartNode & rNode)
    3694                 :            : {
    3695                 :            : 
    3696                 :            :     ww8::WW8TableNodeInfo::Pointer_t pNodeInfo =
    3697         [ +  - ]:        144 :         mpTableInfo->getTableNodeInfo( &rNode );
    3698                 :            : 
    3699         [ -  + ]:        144 :     if (pNodeInfo.get() != NULL)
    3700                 :            :     {
    3701                 :            : #ifdef DBG_UTIL
    3702                 :            :         ::std::clog << pNodeInfo->toString() << ::std::endl;
    3703                 :            : #endif
    3704                 :            : 
    3705 [ #  # ][ #  # ]:          0 :         const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners();
    3706                 :          0 :         ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aIt(aInners.rbegin());
    3707                 :          0 :         ww8::WW8TableNodeInfo::Inners_t::const_reverse_iterator aEnd(aInners.rend());
    3708 [ #  # ][ #  # ]:          0 :         while (aIt != aEnd)
    3709                 :            :         {
    3710 [ #  # ][ #  # ]:          0 :             ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second;
    3711                 :            : 
    3712 [ #  # ][ #  # ]:          0 :             AttrOutput().TableNodeInfoInner(pInner);
         [ #  # ][ #  # ]
    3713         [ #  # ]:          0 :             ++aIt;
    3714         [ #  # ]:          0 :         }
    3715         [ +  - ]:        144 :     }
    3716                 :            : #ifdef DBG_UTIL
    3717                 :            :     ::std::clog << "</OutWW8_SwStartNode>" << ::std::endl;
    3718                 :            : #endif
    3719                 :        144 : }
    3720                 :            : 
    3721                 :        144 : void MSWordExportBase::OutputEndNode( const SwEndNode &rNode )
    3722                 :            : {
    3723                 :            : #ifdef DBG_UTIL
    3724                 :            : // whoever has need of the missing function should go and implement it!
    3725                 :            : // This piece of code always breaks builds...
    3726                 :            : //    ::std::clog << "<OutWW8_SwEndNode>" << dbg_out(&rNode) << ::std::endl;
    3727                 :            : #endif
    3728                 :            : 
    3729         [ +  - ]:        144 :     ww8::WW8TableNodeInfo::Pointer_t pNodeInfo = mpTableInfo->getTableNodeInfo( &rNode );
    3730                 :            : 
    3731         [ -  + ]:        144 :     if (pNodeInfo.get() != NULL)
    3732                 :            :      {
    3733                 :            : #ifdef DBG_UTIL
    3734                 :            :         ::std::clog << pNodeInfo->toString() << ::std::endl;
    3735                 :            : #endif
    3736                 :            : 
    3737 [ #  # ][ #  # ]:          0 :         const ww8::WW8TableNodeInfo::Inners_t aInners = pNodeInfo->getInners();
    3738                 :          0 :         ww8::WW8TableNodeInfo::Inners_t::const_iterator aIt(aInners.begin());
    3739                 :          0 :         ww8::WW8TableNodeInfo::Inners_t::const_iterator aEnd(aInners.end());
    3740         [ #  # ]:          0 :         while (aIt != aEnd)
    3741                 :            :          {
    3742         [ #  # ]:          0 :             ww8::WW8TableNodeInfoInner::Pointer_t pInner = aIt->second;
    3743 [ #  # ][ #  # ]:          0 :             AttrOutput().TableNodeInfoInner(pInner);
         [ #  # ][ #  # ]
    3744                 :          0 :             ++aIt;
    3745         [ #  # ]:          0 :          }
    3746         [ +  - ]:        144 :      }
    3747                 :            : #ifdef DBG_UTIL
    3748                 :            :     ::std::clog << "</OutWW8_SwEndNode>" << ::std::endl;
    3749                 :            : #endif
    3750                 :        144 : }
    3751                 :            : 
    3752                 :          0 : const NfKeywordTable & MSWordExportBase::GetNfKeywordTable()
    3753                 :            : {
    3754         [ #  # ]:          0 :     if (pKeyMap.get() == NULL)
    3755                 :            :     {
    3756         [ #  # ]:          0 :         pKeyMap.reset(new NfKeywordTable);
    3757                 :          0 :         NfKeywordTable & rKeywordTable = *pKeyMap;
    3758 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_D] = "d";
    3759 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_DD] = "dd";
    3760 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_DDD] = "ddd";
    3761 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_DDDD] = "dddd";
    3762 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_M] = "M";
    3763 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_MM] = "MM";
    3764 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_MMM] = "MMM";
    3765 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_MMMM] = "MMMM";
    3766 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_NN] = "ddd";
    3767 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_NNN] = "dddd";
    3768 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_NNNN] = "dddd";
    3769 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_YY] = "yy";
    3770 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_YYYY] = "yyyy";
    3771 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_H] = "H";
    3772 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_HH] = "HH";
    3773 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_MI] = "m";
    3774 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_MMI] = "mm";
    3775 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_S] = "s";
    3776 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_SS] = "ss";
    3777 [ #  # ][ #  # ]:          0 :         rKeywordTable[NF_KEY_AMPM] = "AM/PM";
    3778                 :            :     }
    3779                 :            : 
    3780                 :          0 :     return *pKeyMap;
    3781 [ +  - ][ +  - ]:         54 : }
    3782                 :            : 
    3783                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10