LCOV - code coverage report
Current view: top level - sw/source/filter/ww8 - wrtww8.hxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 89 102 87.3 %
Date: 2014-04-11 Functions: 85 100 85.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
      21             : #define INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
      22             : 
      23             : #include <sot/storage.hxx>
      24             : #include <tools/solar.h>
      25             : #include <tools/gen.hxx>
      26             : #include <editeng/editdata.hxx>
      27             : #include <boost/optional.hpp>
      28             : 
      29             : #include <map>
      30             : #include <vector>
      31             : 
      32             : #include <shellio.hxx>
      33             : #include <wrt_fn.hxx>
      34             : 
      35             : #include "ww8struc.hxx"
      36             : #include "ww8scan.hxx"
      37             : #include "fields.hxx"
      38             : #include "types.hxx"
      39             : #include "writerhelper.hxx"
      40             : #include "../inc/msfilter.hxx"
      41             : #include <expfld.hxx>
      42             : 
      43             : #include <vcl/graph.hxx>
      44             : class SvxBrushItem;
      45             : 
      46             : // einige Forward Deklarationen
      47             : class SwWW8AttrIter;
      48             : namespace msfilter
      49             : {
      50             :     class MSCodec_Std97;
      51             : }
      52             : 
      53             : namespace editeng { class SvxBorderLine; }
      54             : 
      55             : class AttributeOutputBase;
      56             : class DocxAttributeOutput;
      57             : class RtfAttributeOutput;
      58             : class BitmapPalette;
      59             : class SwEscherEx;
      60             : class DateTime;
      61             : class Font;
      62             : class MSWordExportBase;
      63             : class SdrObject;
      64             : class SfxItemSet;
      65             : class SvStream;
      66             : class SvxFontItem;
      67             : class SvxBoxItem;
      68             : class SwAttrSet;
      69             : class SwCharFmt;
      70             : class SwCntntNode;
      71             : class SwField;
      72             : class SwFmt;
      73             : class SwFmtCntnt;
      74             : class SwFmtFtn;
      75             : class SwFrmFmt;
      76             : class SwGrfNode;
      77             : class SwModify;
      78             : class SwNumFmt;
      79             : class SwNumRule;
      80             : class SwNumRuleTbl;
      81             : class SwPageDesc;
      82             : class SwFmtPageDesc;
      83             : class SwOLENode;
      84             : class SwPostItField;
      85             : class SwRedlineData;
      86             : class SwSectionFmt;
      87             : class SwSectionNode;
      88             : class SwTableNode;
      89             : class SwTOXType;
      90             : class SwTxtFmtColl;
      91             : class SwTxtNode;
      92             : class SwWW8WrGrf;
      93             : class SwWW8Writer;
      94             : class MSWordStyles;
      95             : class WW8AttributeOutput;
      96             : class WW8Export;
      97             : class MSWordAttrIter;
      98             : class WW8_WrFkp;
      99             : class WW8_WrPlc0;
     100             : class WW8_WrPlc1;
     101             : class WW8_WrPlcFld;
     102             : class WW8_WrMagicTable;
     103             : class WW8_WrPlcFtnEdn;
     104             : class WW8_WrPlcPn;
     105             : class WW8_WrPlcAnnotations;
     106             : class MSWordSections;
     107             : class WW8_WrPlcTxtBoxes;
     108             : class WW8_WrPct;            // Verwaltung
     109             : class WW8_WrtBookmarks;
     110             : class WW8_WrtRedlineAuthor;
     111             : class SvxMSExportOLEObjects;
     112             : class SwMSConvertControls;
     113             : class WW8_WrPc;
     114             : 
     115             : namespace com { namespace sun { namespace star { namespace embed {
     116             : class XEmbeddedObject;
     117             : } } } }
     118             : typedef std::map<const com::sun::star::embed::XEmbeddedObject*, sal_Int32> WW8OleMap;
     119             : struct WW8_PdAttrDesc;
     120             : class SvxBrushItem;
     121             : 
     122             : #include "WW8TableInfo.hxx"
     123             : 
     124             : #define GRF_MAGIC_1 0x12    // 3 magic Bytes fuer PicLocFc-Attribute
     125             : #define GRF_MAGIC_2 0x34
     126             : #define GRF_MAGIC_3 0x56
     127             : #define GRF_MAGIC_321 0x563412L
     128             : 
     129             : #define OLE_PREVIEW_AS_EMF  //If we want to export ole2 previews as emf in ww8+
     130             : 
     131             : typedef sal_uInt8 FieldFlags;
     132             : namespace nsFieldFlags // for InsertField- Method
     133             : {
     134             :     const FieldFlags WRITEFIELD_START         = 0x01;
     135             :     const FieldFlags WRITEFIELD_CMD_START     = 0x02;
     136             :     const FieldFlags WRITEFIELD_CMD_END     = 0x04;
     137             :     const FieldFlags WRITEFIELD_END         = 0x10;
     138             :     const FieldFlags WRITEFIELD_CLOSE         = 0x20;
     139             :     const FieldFlags WRITEFIELD_ALL         = 0xFF;
     140             : }
     141             : 
     142             : enum TxtTypes  //enums for TextTypes
     143             : {
     144             :     TXT_MAINTEXT = 0, /*TXT_FTNEDN = 1,*/ TXT_HDFT = 2, TXT_FTN = 3,
     145             :     TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7
     146             : };
     147             : 
     148        1219 : struct WW8_SepInfo
     149             : {
     150             :     const SwPageDesc* pPageDesc;
     151             :     const SwSectionFmt* pSectionFmt;
     152             :     const SwNode* pPDNd;
     153             :     const SwTxtNode* pNumNd;
     154             :     sal_uLong  nLnNumRestartNo;
     155             :     ::boost::optional<sal_uInt16> oPgRestartNo;
     156             : 
     157             :     WW8_SepInfo()
     158             :         : pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0)
     159             : 
     160             :     {}
     161             : 
     162         385 :     WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt,
     163             :         sal_uLong nLnRestart, ::boost::optional<sal_uInt16> oPgRestart = boost::none, const SwNode* pNd = NULL )
     164             :         : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ),
     165         385 :           nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart )
     166         385 :     {}
     167             : 
     168             :     bool IsProtected() const;
     169             : };
     170             : 
     171             : /// Class to collect and output the sections/headers/footers.
     172             : // Plc fuer PageDescs -> Sepx ( Section Extensions )
     173             : class MSWordSections
     174             : {
     175             : protected:
     176             :     bool mbDocumentIsProtected;
     177             :     std::vector<WW8_SepInfo> aSects;
     178             : 
     179             :     void CheckForFacinPg( WW8Export& rWrt ) const;
     180             :     void WriteOlst( WW8Export& rWrt, const WW8_SepInfo& rSectionInfo );
     181             :     void NeedsDocumentProtected(const WW8_SepInfo &rInfo);
     182             : 
     183             :     //No copy, no assign
     184             :     MSWordSections( const MSWordSections& );
     185             :     MSWordSections& operator=( const MSWordSections& );
     186             : public:
     187             :     MSWordSections( MSWordExportBase& rExport );
     188             :     virtual ~MSWordSections();
     189             : 
     190             :     virtual bool HeaderFooterWritten();
     191             : 
     192             :     void AppendSection( const SwPageDesc* pPd,
     193             :                     const SwSectionFmt* pSectionFmt = 0,
     194             :                     sal_uLong nLnNumRestartNo = 0 );
     195             :     void AppendSection( const SwFmtPageDesc& rPd,
     196             :                     const SwNode& rNd,
     197             :                     const SwSectionFmt* pSectionFmt,
     198             :                     sal_uLong nLnNumRestartNo );
     199             :     void SetNum( const SwTxtNode* pNumNd );
     200             : 
     201             :     /// Number of columns based on the most recent WW8_SepInfo.
     202             :     sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
     203             : 
     204             :     /// Number of columns of the provided WW8_SepInfo.
     205             :     sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const;
     206             : 
     207          27 :     bool DocumentIsProtected() const { return mbDocumentIsProtected; }
     208             : 
     209             :     /// The most recent WW8_SepInfo.
     210             :     const WW8_SepInfo* CurrentSectionInfo();
     211             : 
     212             :     static void SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
     213             :                                   sal_uInt8 nFlag );
     214             :     static void SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
     215             :                                    sal_uInt8 nFlag );
     216             : 
     217             :     /// Should we output borders?
     218             :     static bool HasBorderItem( const SwFmt& rFmt );
     219             : };
     220             : 
     221             : class WW8_WrPlcSepx : public MSWordSections
     222             : {
     223             :     std::vector<WW8_CP> aCps;
     224             :     ::std::vector< ::boost::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes;
     225             :     // hack to prevent adding sections in endnotes
     226             :     bool m_bHeaderFooterWritten;
     227             :     WW8_WrPlc0* pTxtPos;        // Pos der einzelnen Header / Footer
     228             : 
     229             :     // No copy, no assign
     230             :     WW8_WrPlcSepx( const WW8_WrPlcSepx& );
     231             :     WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& );
     232             : 
     233             : public:
     234             :     WW8_WrPlcSepx( MSWordExportBase& rExport );
     235             :     virtual ~WW8_WrPlcSepx();
     236             : 
     237             :     virtual bool HeaderFooterWritten() SAL_OVERRIDE; // override
     238             : 
     239             :     void AppendSep( WW8_CP nStartCp,
     240             :                     const SwPageDesc* pPd,
     241             :                     const SwSectionFmt* pSectionFmt = 0,
     242             :                     sal_uLong nLnNumRestartNo = 0 );
     243             :     void AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPd,
     244             :                     const SwNode& rNd,
     245             :                     const SwSectionFmt* pSectionFmt,
     246             :                     sal_uLong nLnNumRestartNo );
     247          12 :     void Finish( WW8_CP nEndCp ) { aCps.push_back( nEndCp ); }
     248             : 
     249             :     bool WriteKFTxt( WW8Export& rWrt );
     250             :     void WriteSepx( SvStream& rStrm ) const;
     251             :     void WritePlcSed( WW8Export& rWrt ) const;
     252             :     void WritePlcHdd( WW8Export& rWrt ) const;
     253             : 
     254             : private:
     255             :     void WriteFtnEndTxt( WW8Export& rWrt, sal_uLong nCpStt );
     256             : public:
     257             :     void OutHeaderFooter(WW8Export& rWrt, bool bHeader,
     258             :             const SwFmt& rFmt, sal_uLong& rCpPos, sal_uInt8 nHFFlags, sal_uInt8 nFlag,  sal_uInt8 nBreakCode);
     259             : };
     260             : 
     261             : // class WW8_WrPct to construct the piece table
     262             : class WW8_WrPct
     263             : {
     264             :     boost::ptr_vector<WW8_WrPc > aPcts;
     265             :     WW8_FC nOldFc;
     266             :     bool bIsUni;
     267             : public:
     268             :     WW8_WrPct(WW8_FC nStartFc, bool bSaveUniCode);
     269             :     ~WW8_WrPct();
     270             :     void AppendPc(WW8_FC nStartFc, bool bIsUnicode);
     271             :     void WritePc( WW8Export& rWrt );
     272             :     void SetParaBreak();
     273         731 :     bool IsUnicode() const  { return bIsUni; }
     274             :     WW8_CP Fc2Cp( sal_uLong nFc ) const;
     275             : };
     276             : 
     277             : /// Collects and outputs fonts.
     278       15115 : class wwFont
     279             : {
     280             : //In some future land the stream could be converted to a nice stream interface
     281             : //and we could have harmony
     282             : private:
     283             :     sal_uInt8 maWW8_FFN[6];
     284             :     OUString msFamilyNm;
     285             :     OUString msAltNm;
     286             :     bool mbAlt;
     287             :     bool mbWrtWW8;
     288             :     FontPitch mePitch;
     289             :     FontFamily meFamily;
     290             :     rtl_TextEncoding meChrSet;
     291             : public:
     292             :     wwFont( const OUString &rFamilyName, FontPitch ePitch, FontFamily eFamily,
     293             :         rtl_TextEncoding eChrSet, bool bWrtWW8 );
     294             :     bool Write( SvStream *pTableStram ) const;
     295             :     void WriteDocx( DocxAttributeOutput* rAttrOutput ) const;
     296             :     void WriteRtf( const RtfAttributeOutput* rAttrOutput ) const;
     297         296 :     OUString GetFamilyName() const { return OUString( msFamilyNm ); }
     298             :     friend bool operator < (const wwFont &r1, const wwFont &r2);
     299             : };
     300             : 
     301         340 : class wwFontHelper
     302             : {
     303             : private:
     304             :     /// Keep track of fonts that need to be exported.
     305             :     ::std::map<wwFont, sal_uInt16> maFonts;
     306             :     bool mbWrtWW8;
     307             : 
     308             :     /// Convert from fast insertion map to linear vector in the order that we want to write.
     309             :     ::std::vector< const wwFont* > AsVector() const;
     310             : 
     311             : public:
     312         340 :     wwFontHelper() : mbWrtWW8(false), bLoadAllFonts(false) {}
     313             :     /// rDoc used only to get the initial standard font(s) in use.
     314             :     void InitFontTable(bool bWrtWW8, const SwDoc& rDoc);
     315             :     sal_uInt16 GetId(const Font& rFont);
     316             :     sal_uInt16 GetId(const SvxFontItem& rFont);
     317             :     sal_uInt16 GetId(const wwFont& rFont);
     318             :     void WriteFontTable( SvStream *pTableStream, WW8Fib& pFib );
     319             :     void WriteFontTable( DocxAttributeOutput& rAttrOutput );
     320             :     void WriteFontTable( const RtfAttributeOutput& rAttrOutput );
     321             : 
     322             :     /// If true, all fonts are loaded before processing the document.
     323             :     sal_uInt8 bLoadAllFonts: 1;
     324             : };
     325             : 
     326          41 : class DrawObj
     327             : {
     328             : public:
     329             :     WW8_CP mnCp;                // CP-Pos of references
     330             :     sal_uInt32 mnShapeId;       // ShapeId for the SwFrmFmts
     331             :     sw::Frame maCntnt;          // the frame itself
     332             :     Point maParentPos;          // Points
     333             :     sal_Int32 mnThick;          // Border Thicknesses
     334             :     short mnDirection;          // If BiDi or not
     335             :     unsigned int mnHdFtIndex;   // 0 for main text, +1 for each subsequent
     336             :                                 // msword hd/ft
     337             : 
     338           9 :     DrawObj(const sw::Frame &rCntnt, WW8_CP nCp, Point aParentPos, short nDir,
     339             :             unsigned int nHdFtIndex)
     340             :         : mnCp(nCp), mnShapeId(0), maCntnt(rCntnt), maParentPos(aParentPos),
     341           9 :         mnThick(0), mnDirection(nDir), mnHdFtIndex(nHdFtIndex) {}
     342             :     void SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick);
     343             :     DrawObj& operator=(const DrawObj &rOther);
     344             : };
     345             : 
     346             : typedef std::vector<DrawObj> DrawObjVector;
     347             : typedef DrawObjVector::iterator DrawObjIter;
     348             : typedef DrawObjVector::const_iterator cDrawObjIter;
     349             : 
     350             : typedef std::vector<DrawObj *> DrawObjPointerVector;
     351             : typedef DrawObjPointerVector::iterator DrawObjPointerIter;
     352             : 
     353             : class PlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes
     354             : {
     355             : private:
     356             :     DrawObjVector maDrawObjs;  // vector of drawobjs
     357             : protected:
     358             :     virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
     359             :         sal_uInt32 nLen) const = 0;
     360             :     virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const = 0;
     361             : public:
     362          24 :     PlcDrawObj() {}
     363             :     void WritePlc( WW8Export& rWrt ) const;
     364             :     bool Append( WW8Export&, WW8_CP nCp, const sw::Frame& rFmt,
     365             :         const Point& rNdTopLeft );
     366          26 :     int size() { return maDrawObjs.size(); };
     367           4 :     DrawObjVector &GetObjArr() { return maDrawObjs; }
     368             :     virtual ~PlcDrawObj();
     369             : private:
     370             :     //No copying
     371             :     PlcDrawObj(const PlcDrawObj&);
     372             :     PlcDrawObj& operator=(const PlcDrawObj&);
     373             : };
     374             : 
     375          24 : class MainTxtPlcDrawObj : public PlcDrawObj
     376             : {
     377             : public:
     378          12 :     MainTxtPlcDrawObj() {}
     379             : private:
     380             :     virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
     381             :         sal_uInt32 nLen) const SAL_OVERRIDE;
     382             :     virtual WW8_CP GetCpOffset(const WW8Fib &) const SAL_OVERRIDE;
     383             : private:
     384             :     //No copying
     385             :     MainTxtPlcDrawObj(const MainTxtPlcDrawObj&);
     386             :     MainTxtPlcDrawObj& operator=(const MainTxtPlcDrawObj&);
     387             : };
     388             : 
     389          24 : class HdFtPlcDrawObj : public PlcDrawObj
     390             : {
     391             : public:
     392          12 :     HdFtPlcDrawObj() {}
     393             : private:
     394             :     virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
     395             :         sal_uInt32 nLen) const SAL_OVERRIDE;
     396             :     virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const SAL_OVERRIDE;
     397             : private:
     398             :     //No copying
     399             :     HdFtPlcDrawObj(const HdFtPlcDrawObj&);
     400             :     HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&);
     401             : };
     402             : 
     403             : typedef ::std::pair<OUString, sal_uLong> aBookmarkPair;
     404             : typedef std::vector<aBookmarkPair> SwImplBookmarks;
     405             : typedef std::vector<aBookmarkPair>::iterator SwImplBookmarksIter;
     406             : 
     407           0 : class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor
     408             : {
     409             :     public:
     410             :     virtual void Write(Writer &rWrt) SAL_OVERRIDE;
     411             : };
     412             : 
     413             : /** Structure that is used to save some of the WW8Export/DocxExport data.
     414             : 
     415             :     It is used to be able to recurse inside of the WW8Export/DocxExport (eg.
     416             :     for the needs of the tables) - you need to tall WriteText() from there with
     417             :     new values of PaM etc.
     418             : 
     419             :     It must contain all the stuff that might be saved either in WW8Export or in
     420             :     DocxExport, because it makes no sense to do it abstract, and specialize it
     421             :     for each of the cases.  If you implement other *Export, just add the needed
     422             :     members here, and store them in the appropriate SaveData() method.
     423             :  */
     424             : struct MSWordSaveData
     425             : {
     426             :     Point* pOldFlyOffset;
     427             :     RndStdIds eOldAnchorType;
     428             :     ww::bytes* pOOld;                ///< WW8Export only
     429             :     SwPaM* pOldPam, *pOldEnd;
     430             :     const sw::Frame* pOldFlyFmt;
     431             :     const SwPageDesc* pOldPageDesc;
     432             : 
     433             :     sal_uInt8 bOldWriteAll : 1;          ///< WW8Export only
     434             :     sal_uInt8 bOldOutTable : 1;
     435             :     sal_uInt8 bOldIsInTable: 1;
     436             :     sal_uInt8 bOldFlyFrmAttrs : 1;
     437             :     sal_uInt8 bOldStartTOX : 1;
     438             :     sal_uInt8 bOldInWriteTOX : 1;
     439             :     // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend der
     440             :     // Ausgabe von Spezial-Texten veraendert wird.
     441             : };
     442             : 
     443             : /// Base class for WW8Export and DocxExport
     444             : class MSWordExportBase
     445             : {
     446             : public:
     447             :     wwFontHelper maFontHelper;
     448             :     std::vector<sal_uLong> maChapterFieldLocs;
     449             :     typedef std::vector<sal_uLong>::const_iterator mycCFIter;
     450             :     OUString aMainStg;
     451             :     std::vector<const SwTOXType*> aTOXArr;
     452             :     const SfxItemSet* pISet;    // fuer Doppel-Attribute
     453             :     WW8_WrPct*  pPiece;         // Pointer auf Piece-Table
     454             :     SwNumRuleTbl* pUsedNumTbl;  // alle used NumRules
     455             :     const SwTxtNode *mpTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft
     456             :     std::map< sal_uInt16, sal_uInt16 > aRuleDuplicates; //map to Duplicated numrules
     457             :     std::stack< sal_Int32 > m_aCurrentCharPropStarts; ///< To remember the position in a run.
     458             :     WW8_WrtBookmarks* pBkmks;
     459             :     WW8_WrtRedlineAuthor* pRedlAuthors;
     460             :     BitmapPalette* pBmpPal;
     461             :     boost::shared_ptr<NfKeywordTable> pKeyMap;
     462             :     SvxMSExportOLEObjects* pOLEExp;
     463             :     SwMSConvertControls* pOCXExp;
     464             :     WW8OleMap m_aOleMap;    // To remember all already exported ole objects
     465             :     ww8::WW8TableInfo::Pointer_t mpTableInfo;
     466             : 
     467             :     sal_uInt16 nCharFmtStart;
     468             :     sal_uInt16 nFmtCollStart;
     469             :     sal_uInt16 nStyleBeforeFly;     ///< Style-Nummer des Nodes,
     470             :                                 ///<       in/an dem ein Fly verankert ist
     471             :     sal_uInt16 nLastFmtId;          ///< Style of last TxtNode in normal range
     472             :     sal_uInt16 nUniqueList;         ///< current number for creating unique list names
     473             :     unsigned int mnHdFtIndex;
     474             : 
     475             :     sal_uInt16 mnRedlineMode;       ///< Remember the original redline mode
     476             : 
     477             : public:
     478             :     /* implicit bookmark vector containing pairs of node indexes and bookmark names */
     479             :     SwImplBookmarks maImplicitBookmarks;
     480             :     sw::Frames maFrames;             // The floating frames in this document
     481             :     const SwPageDesc *pAktPageDesc;
     482             :     WW8_WrPlcPn* pPapPlc;
     483             :     WW8_WrPlcPn* pChpPlc;
     484             :     MSWordAttrIter* pChpIter;
     485             :     MSWordStyles* pStyles;
     486             :     WW8_WrPlcAnnotations* pAtn;
     487             :     WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs;
     488             : 
     489             :     const sw::Frame *mpParentFrame; // If set we are exporting content inside
     490             :                                     // a frame, e.g. a graphic node
     491             : 
     492             :     Point* pFlyOffset;              // zur Justierung eines im Writer als
     493             :     RndStdIds eNewAnchorType;       // Zeichen gebundenen Flys, der im WW
     494             :                                     // Absatzgebunden wird.
     495             : 
     496             :     WW8_WrPlcFld* pFldMain;         // fields in MainText
     497             :     WW8_WrPlcFld* pFldHdFt;         // fields in Header/Footer
     498             :     WW8_WrPlcFld* pFldFtn;          // fields in FootNotes
     499             :     WW8_WrPlcFld* pFldEdn;          // fields in EndNotes
     500             :     WW8_WrPlcFld* pFldAtn;          // fields in Annotations
     501             :     WW8_WrPlcFld* pFldTxtBxs;       // fields in textboxes
     502             :     WW8_WrPlcFld* pFldHFTxtBxs;     // fields in header/footer textboxes
     503             :     WW8_WrMagicTable *pMagicTable;  // keeps track of table cell positions, and
     504             :                                     // marks those that contain graphics,
     505             :                                     // which is required to make word display
     506             :                                     // graphics inside tables
     507             :     SwWW8WrGrf* pGrf;
     508             :     const SwAttrSet* pStyAttr;      // StyleAttr for Tabs
     509             :     const SwModify* pOutFmtNode;    // write Format or Node
     510             :     const SwFmt *pCurrentStyle;     // iff bStyDef=true, then this store the current style
     511             : 
     512             :     MainTxtPlcDrawObj *pSdrObjs;   // Draw-/Fly-Objects
     513             :     HdFtPlcDrawObj *pHFSdrObjs;     // Draw-/Fly-Objects in header or footer
     514             : 
     515             :     SwEscherEx* pEscher;            // escher export class
     516             :     // #i43447# - removed
     517             : //    SwTwips nFlyWidth, nFlyHeight;  // Fuer Anpassung Graphic
     518             : 
     519             :     sal_uInt8 nTxtTyp;
     520             : 
     521             :     bool bStyDef : 1;           // should Style be written?
     522             :     bool bBreakBefore : 1;      // Breaks are being written 2 times
     523             :     bool bOutKF : 1;            // Header/Footer texts are being written
     524             :     bool bOutFlyFrmAttrs : 1;   // Frame-attr of Flys are being written
     525             :     bool bOutPageDescs : 1;     ///< PageDescs (section properties) are being written
     526             :     bool bOutFirstPage : 1;     // write Attrset of FirstPageDesc
     527             :     bool bOutTable : 1;         // table is being written
     528             :                                      // ( wird zB bei Flys in Tabelle zurueckgesetzt )
     529             :     bool bOutGrf : 1;           // graphics are being written
     530             :     bool bInWriteEscher : 1;    // in write textboxes
     531             :     bool bStartTOX : 1;         // true: a TOX is startet
     532             :     bool bInWriteTOX : 1;       // true: all content are in a TOX
     533             :     bool bFtnAtTxtEnd : 1;      // true: all FTN at Textend
     534             :     bool bEndAtTxtEnd : 1;      // true: all END at Textend
     535             :     bool bHasHdr : 1;
     536             :     bool bHasFtr : 1;
     537             :     bool bSubstituteBullets : 1; // true: SubstituteBullet() gets called
     538             :     bool bTabInTOC : 1; //true for TOC field flag 'w'
     539             : 
     540             :     bool bHideTabLeaderAndPageNumbers : 1 ; // true: the 'z' field of TOC is set.
     541             :     bool mbExportModeRTF;
     542             :     bool mbOutOutlineOnly;   // export outline nodes, only (send outline to clipboard/presentation)
     543             : 
     544             :     SwDoc *pDoc;
     545             :     SwPaM *pCurPam, *pOrigPam;
     546             : 
     547             :     /// Stack to remember the nesting (see MSWordSaveData for more)
     548             :     ::std::stack< MSWordSaveData > maSaveData;
     549             : 
     550             :     /// Used to split the runs according to the bookmarks start and ends
     551             :     typedef std::vector< ::sw::mark::IMark* > IMarkVector;
     552             :     IMarkVector m_rSortedBookmarksStart;
     553             :     IMarkVector m_rSortedBookmarksEnd;
     554             :     IMarkVector m_rSortedAnnotationMarksStart;
     555             :     IMarkVector m_rSortedAnnotationMarksEnd;
     556             : 
     557             : public:
     558             :     /// The main function to export the document.
     559             :     void ExportDocument( bool bWriteAll );
     560             : 
     561             :     /// Iterate through the nodes and call the appropriate OutputNode() on them.
     562             :     void WriteText();
     563             : 
     564             :     /// Return whether cuurently exported node is in table.
     565             :     bool IsInTable() const;
     566             : 
     567             :     /// Set the pCurPam appropriately and call WriteText().
     568             :     ///
     569             :     /// Used to export paragraphs in footnotes/endnotes/etc.
     570             :     void WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp );
     571             : 
     572             :     /// Export the pool items to attributes (through an attribute output class).
     573             :     void ExportPoolItemsToCHP( sw::PoolItems &rItems, sal_uInt16 nScript );
     574             : 
     575             :     /// Return the numeric id of the numbering rule
     576             :     sal_uInt16 GetId( const SwNumRule& rNumRule );
     577             : 
     578             :     /// Return the numeric id of the style.
     579             :     sal_uInt16 GetId( const SwTxtFmtColl& rColl ) const;
     580             : 
     581             :     /// Return the numeric id of the style.
     582             :     sal_uInt16 GetId( const SwCharFmt& rFmt ) const;
     583             : 
     584             :     sal_uInt16 GetId( const SwTOXType& rTOXType );
     585             : 
     586             :     /// Return the numeric id of the font (and add it to the font list if needed)
     587        6486 :     sal_uInt16 GetId( const SvxFontItem& rFont)
     588             :     {
     589        6486 :         return maFontHelper.GetId(rFont);
     590             :     }
     591             :     /// @overload
     592         296 :     sal_uInt16 GetId( const wwFont& rFont)
     593             :     {
     594         296 :         return maFontHelper.GetId(rFont);
     595             :     }
     596             : 
     597             :     const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
     598             : 
     599             :     /// Find the reference.
     600             :     bool HasRefToObject( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
     601             : 
     602             :     /// Find the bookmark name.
     603             :     OUString GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
     604             : 
     605             :     /// Add a bookmark converted to a Word name.
     606             :     void AppendWordBookmark( const OUString& rName );
     607             : 
     608             :     /// Use OutputItem() on an item set according to the parameters.
     609             :     void OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, sal_uInt16 nScript, bool bExportParentItemSet );
     610             : 
     611             :     short GetDefaultFrameDirection( ) const;
     612             : 
     613             :     /// Right to left?
     614             :     short TrueFrameDirection( const SwFrmFmt& rFlyFmt ) const;
     615             : 
     616             :     /// Right to left?
     617             :     short GetCurrentPageDirection() const;
     618             : 
     619             :     /// In case of numbering restart.
     620             : 
     621             :     /// List is set to restart at a particular value so for export make a
     622             :     /// completely new list based on this one and export that instead,
     623             :     /// which duplicates words behaviour in this respect.
     624             :     sal_uInt16 DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal );
     625             : 
     626             :     /// Access to the attribute output class.
     627             :     virtual AttributeOutputBase& AttrOutput() const = 0;
     628             : 
     629             :     /// Access to the sections/headers/footres.
     630             :     virtual MSWordSections& Sections() const = 0;
     631             : 
     632             :     /// Determines if the format is expected to support unicode.
     633             :     virtual bool SupportsUnicode() const = 0;
     634             : 
     635             :     /// Determines if column break with one column should be exported or not.
     636             :     virtual bool SupportsOneColumnBreak() const = 0;
     637             : 
     638             :     /// Determines if the import filter already quoted fields or not.
     639             :     virtual bool FieldsQuoted() const = 0;
     640             : 
     641             :     /// Determines the Section Breaks are to be added for TOX Section
     642             :     virtual bool AddSectionBreaksForTOX() const = 0;
     643             : 
     644             :     /// Used to filter out attributes that can be e.g. written to .doc but not to .docx
     645        8805 :     virtual bool ignoreAttributeForStyles( sal_uInt16 /*nWhich*/ ) const { return false; }
     646             : 
     647             :     /// Guess the script (asian/western).
     648             :     ///
     649             :     /// Sadly word does not have two different sizes for asian font size and
     650             :     /// western font size, it has two different fonts, but not sizes, so we
     651             :     /// have to use our guess as to the script used and disable the export of
     652             :     /// one type. The same occurs for font weight and posture (bold and
     653             :     /// italic).
     654             :     ///
     655             :     /// In addition WW7- has only one character language identifier while WW8+
     656             :     /// has two
     657             :     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) = 0;
     658             : 
     659             :     virtual void AppendBookmarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) = 0;
     660             : 
     661             :     virtual void AppendBookmark( const OUString& rName, bool bSkip = false ) = 0;
     662             : 
     663             :     virtual void AppendAnnotationMarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) = 0;
     664             : 
     665             :     //For i120928,add this interface to export graphic of bullet
     666             :     virtual void ExportGrfBullet(const SwTxtNode& rNd) = 0;
     667             : 
     668             :     // FIXME probably a hack...
     669             :     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0;
     670             : 
     671             :     // FIXME definitely a hack, must not be here - it can't do anything
     672             :     // sensible for docx
     673             :     virtual void WriteChar( sal_Unicode c ) = 0;
     674             : 
     675             :     /// Output attributes.
     676             :     void OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt = false );
     677             : 
     678             :     /// Getter for pISet.
     679        4652 :     const SfxItemSet* GetCurItemSet() const { return pISet; }
     680             : 
     681             :     /// Setter for pISet.
     682        9190 :     void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; }
     683             : 
     684             :     /// Remember some of the memebers so that we can recurse in WriteText().
     685             :     virtual void SaveData( sal_uLong nStt, sal_uLong nEnd );
     686             : 
     687             :     /// Restore what was saved in SaveData().
     688             :     virtual void RestoreData();
     689             : 
     690             :     /// The return value indicates, if a follow page desc is written.
     691             :     bool OutputFollowPageDesc( const SfxItemSet* pSet,
     692             :                                const SwTxtNode* pNd );
     693             : 
     694             :     /// Write header/footer text.
     695             :     void WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader);
     696             : 
     697             :     /// Format of the section.
     698             :     const SwSectionFmt* GetSectionFormat( const SwNode& rNd ) const;
     699             : 
     700             :     /// Line number of the section start.
     701             :     sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const;
     702             : 
     703             :     /// Start new section.
     704             :     void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false, bool isTextNodeEmpty = false);
     705             : 
     706             :     /// Write section properties.
     707             :     ///
     708             :     /// pA is ignored for docx.
     709             :     void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = NULL );
     710             : 
     711             :     /// Output the numbering table.
     712             :     virtual void WriteNumbering() = 0;
     713             : 
     714             :     /// Write static data of SwNumRule - LSTF
     715             :     void NumberingDefinitions();
     716             : 
     717             :     /// Write all Levels for all SwNumRules - LVLF
     718             :     void AbstractNumberingDefinitions();
     719             : 
     720             :     // Convert the bullet according to the font.
     721             :     void SubstituteBullet( OUString& rNumStr, rtl_TextEncoding& rChrSet,
     722             :         OUString& rFontName ) const;
     723             : 
     724             :     /// No-op for the newer WW versions.
     725           0 :     virtual void OutputOlst( const SwNumRule& /*rRule*/ ) {}
     726             : 
     727             :     /// Setup the pA's info.
     728         303 :     virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {}
     729             : 
     730             :     /// Top node of host page when in header/footer.
     731         636 :     void SetHdFtPageRoot( const SwTxtNode *pNd ) { mpTopNodeOfHdFtPage = pNd; }
     732             : 
     733             :     /// Top node of host page when in header/footer.
     734         318 :     const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; }
     735             : 
     736             :     /// Output the actual headers and footers.
     737             :     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
     738             :             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
     739             :         sal_uInt8 nBreakCode) = 0;
     740             : 
     741             :     /// Write the field
     742             :     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
     743             :             const OUString& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) = 0;
     744             : 
     745             :     /// Write the data of the form field
     746             :     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
     747             :     virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
     748             : 
     749             :     virtual void DoComboBox(const OUString &rName,
     750             :                     const OUString &rHelp,
     751             :                     const OUString &ToolTip,
     752             :                     const OUString &rSelected,
     753             :                     com::sun::star::uno::Sequence<OUString> &rListItems) = 0;
     754             : 
     755             :     virtual void DoFormText(const SwInputField * pFld) = 0;
     756             : 
     757             :     static bool NoPageBreakSection( const SfxItemSet *pSet );
     758             : 
     759             :     // Compute the number format for WW dates
     760             :     bool GetNumberFmt(const SwField& rFld, OUString& rStr);
     761             : 
     762             :     virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) = 0;
     763             : 
     764             :     const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const;
     765             : 
     766             :     /// Returns the index of a picture bullet, used in numberings.
     767             :     int GetGrfIndex(const SvxBrushItem& rBrush);
     768             : 
     769             : protected:
     770             :     /// Format-dependent part of the actual export.
     771             :     virtual void ExportDocument_Impl() = 0;
     772             : 
     773             :     /// Get the next position in the text node to output
     774             :     virtual sal_Int32 GetNextPos( SwWW8AttrIter* pAttrIter, const SwTxtNode& rNode, sal_Int32 nAktPos );
     775             : 
     776             :     /// Update the information for GetNextPos().
     777             :     virtual void UpdatePosition( SwWW8AttrIter* pAttrIter, sal_Int32 nAktPos, sal_Int32 nEnd );
     778             : 
     779             :     /// Output SwTxtNode
     780             :     virtual void OutputTextNode( const SwTxtNode& );
     781             : 
     782             :     /// Output SwTableNode
     783             :     void OutputTableNode( const SwTableNode& );
     784             : 
     785             :     /// Setup the chapter fields (maChapterFieldLocs).
     786             :     void GatherChapterFields();
     787             : 
     788             :     void AddLinkTarget( const OUString& rURL );
     789             :     void CollectOutlineBookmarks( const SwDoc &rDoc );
     790             : 
     791             :     bool SetAktPageDescFromNode(const SwNode &rNd);
     792             :     bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const;
     793             :     bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const;
     794             : 
     795             :     virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) = 0;
     796             : 
     797             :     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
     798             :                                      const SwNode& rNd,
     799             :                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
     800             :                                      const SwPageDesc* pNewPgDesc = 0 ) = 0;
     801             : 
     802             :     /// Return value indicates if an inherited outline numbering is suppressed.
     803             :     virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0;
     804             : 
     805             :     /// Output SwStartNode
     806             :     virtual void OutputStartNode( const SwStartNode& );
     807             : 
     808             :     /// Output SwEndNode
     809             :     virtual void OutputEndNode( const SwEndNode& );
     810             : 
     811             :     /// Output SwGrfNode
     812             :     virtual void OutputGrfNode( const SwGrfNode& ) = 0;
     813             : 
     814             :     /// Output SwOLENode
     815             :     virtual void OutputOLENode( const SwOLENode& ) = 0;
     816             : 
     817             :     virtual void OutputLinkedOLE( const OUString& ) = 0;
     818             : 
     819             :     /// Output SwSectionNode
     820             :     virtual void OutputSectionNode( const SwSectionNode& );
     821             : 
     822             :     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) = 0;
     823             : 
     824             :     /// Call the right (virtual) function according to the type of the item.
     825             :     ///
     826             :     /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode()
     827             :     void OutputContentNode( const SwCntntNode& );
     828             : 
     829             :     /// Find the nearest bookmark from the current position.
     830             :     ///
     831             :     /// Returns false when there is no bookmark.
     832             :     bool NearestBookmark( sal_Int32& rNearest, const sal_Int32 nAktPos, bool bNextPositionOnly );
     833             : 
     834             :     void GetSortedBookmarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen );
     835             : 
     836             :     bool GetBookmarks( const SwTxtNode& rNd, sal_Int32 nStt, sal_Int32 nEnd,
     837             :             IMarkVector& rArr );
     838             : 
     839             :     /// Find the nearest annotation mark from the current position.
     840             :     ///
     841             :     /// Returns false when there is no annotation mark.
     842             :     bool NearestAnnotationMark( sal_Int32& rNearest, const sal_Int32 nAktPos, bool bNextPositionOnly );
     843             : 
     844             :     void GetSortedAnnotationMarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen );
     845             : 
     846             :     bool GetAnnotationMarks( const SwTxtNode& rNd, sal_Int32 nStt, sal_Int32 nEnd,
     847             :             IMarkVector& rArr );
     848             : 
     849             :     const NfKeywordTable & GetNfKeywordTable();
     850             : 
     851             :     /// Populates m_vecBulletPic with all the bullet graphics used by numberings.
     852             :     int CollectGrfsOfBullets();
     853             :     /// Write the numbering picture bullets.
     854             :     void BulletDefinitions();
     855             :     std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets
     856             : 
     857             : public:
     858             :     MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam );
     859             :     virtual ~MSWordExportBase();
     860             : 
     861             :     // TODO move as much as possible here from WW8Export! ;-)
     862             : 
     863             :     static void CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft );
     864             : 
     865             : private:
     866             :     /// No copying.
     867             :     MSWordExportBase( const MSWordExportBase& );
     868             :     /// No copying.
     869             :     MSWordExportBase& operator=( const MSWordExportBase& );
     870             : };
     871             : 
     872             : /// The writer class that gets called for the WW8 filter.
     873             : class SwWW8Writer: public StgWriter
     874             : {
     875             : // friends to get access to m_pExport
     876             : // FIXME avoid that, this is probably not what we want
     877             : // (if yes, remove the friends, and provide here a GetExport() method)
     878             : friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt);
     879             : 
     880             :     bool       m_bWrtWW8;
     881             :     WW8Export *m_pExport;
     882             :     SfxMedium *mpMedium;
     883             : 
     884             : public:
     885             :     SwWW8Writer(const OUString& rFltName, const OUString& rBaseURL);
     886             :     virtual ~SwWW8Writer();
     887             : 
     888             :     virtual sal_uLong WriteStorage() SAL_OVERRIDE;
     889             :     virtual sal_uLong WriteMedium( SfxMedium& ) SAL_OVERRIDE;
     890             : 
     891             :     // TODO most probably we want to be able to get these in
     892             :     // MSExportFilterBase
     893             :     using Writer::getIDocumentSettingAccess;
     894             : 
     895             : public:
     896             :     static void InsUInt16(ww::bytes &rO, sal_uInt16 n);
     897             :     static void InsUInt32(ww::bytes &rO, sal_uInt32 n);
     898             :     static void InsAsString16(ww::bytes &rO, const OUString& rStr);
     899             :     static void InsAsString8(ww::bytes & O, const OUString& rStr,
     900             :         rtl_TextEncoding eCodeSet);
     901             : 
     902             :     static sal_uLong FillUntil( SvStream& rStrm, sal_uLong nEndPos = 0 );
     903             :     static void FillCount( SvStream& rStrm, sal_uLong nCount );
     904             : 
     905         346 :     static void WriteShort( SvStream& rStrm, sal_Int16 nVal ) { rStrm.WriteInt16( nVal ); }
     906             :     static void WriteShort( SvStream& rStrm, sal_uLong nPos, sal_Int16 nVal );
     907             : 
     908         555 :     static void WriteLong( SvStream& rStrm, sal_Int32 nVal ) { rStrm.WriteInt32( nVal ); }
     909             :     static void WriteLong( SvStream& rStrm, sal_uLong nPos, sal_Int32 nVal );
     910             : 
     911             :     static void WriteString16(SvStream& rStrm, const OUString& rStr,
     912             :         bool bAddZero);
     913             :     static void WriteString8(SvStream& rStrm, const OUString& rStr,
     914             :         bool bAddZero, rtl_TextEncoding eCodeSet);
     915             : 
     916             :     static void WriteString_xstz(SvStream& rStrm, const OUString& rStr, bool bAddZero);
     917             : 
     918             :     bool InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec );
     919             : 
     920             :     using StgWriter::Write;
     921             :     virtual sal_uLong Write( SwPaM&, SfxMedium&, const OUString* = 0 ) SAL_OVERRIDE;
     922             :     //Seems not an expected to provide method to access the private member
     923           0 :     SfxMedium* GetMedia() { return mpMedium; }
     924             : 
     925             : private:
     926             :     /// No copying.
     927             :     SwWW8Writer(const SwWW8Writer&);
     928             :     /// No copying.
     929             :     SwWW8Writer& operator=(const SwWW8Writer&);
     930             : };
     931             : 
     932             : /// Exporter of the binary Word file formats.
     933             : class WW8Export : public MSWordExportBase
     934             : {
     935             : public:
     936             :     ww::bytes* pO;                       ///< Buffer
     937             : 
     938             :     SvStream *pTableStrm, *pDataStrm;   ///< Streams for WW97 Export
     939             : 
     940             :     WW8Fib* pFib;                       ///< File Information Block
     941             :     WW8Dop* pDop;                       ///< DOcument Properties
     942             :     WW8_WrPlcFtnEdn *pFtn;              ///< Footnotes - structure to remember them, and output
     943             :     WW8_WrPlcFtnEdn *pEdn;              ///< Endnotes - structure to remember them, and output
     944             :     WW8_WrPlcSepx* pSepx;               ///< Sections/headers/footers
     945             : 
     946             :     sal_uInt8 bWrtWW8 : 1;                   ///< Write WW95 (false) or WW97 (true) file format
     947             :     bool m_bDot; ///< Template or document.
     948             : 
     949             : protected:
     950             :     SwWW8Writer        *m_pWriter;      ///< Pointer to the writer
     951             :     WW8AttributeOutput *m_pAttrOutput;  ///< Converting attributes to stream data
     952             : 
     953             : private:
     954             :     SvStorageRef       xEscherStg;      /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj
     955             : 
     956             : public:
     957             :     /// Access to the attribute output class.
     958             :     virtual AttributeOutputBase& AttrOutput() const SAL_OVERRIDE;
     959             : 
     960             :     /// Access to the sections/headers/footres.
     961             :     virtual MSWordSections& Sections() const SAL_OVERRIDE;
     962             : 
     963             :     /// False for WW6, true for WW8.
     964        1681 :     virtual bool SupportsUnicode() const SAL_OVERRIDE { return bWrtWW8; }
     965             : 
     966           0 :     virtual bool SupportsOneColumnBreak() const SAL_OVERRIDE { return false; }
     967             : 
     968           0 :     virtual bool FieldsQuoted() const SAL_OVERRIDE { return false; }
     969             : 
     970           0 :     virtual bool AddSectionBreaksForTOX() const SAL_OVERRIDE { return false; }
     971             : private:
     972             :     /// Format-dependent part of the actual export.
     973             :     virtual void ExportDocument_Impl() SAL_OVERRIDE;
     974             : 
     975             :     void PrepareStorage();
     976             :     void WriteFkpPlcUsw();
     977             :     void WriteMainText();
     978             :     void StoreDoc1();
     979             :     void Out_WwNumLvl( sal_uInt8 nWwLevel );
     980             :     void BuildAnlvBulletBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen,
     981             :                               const SwNumFmt& rFmt );
     982             :     static void BuildAnlvBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen,
     983             :                    const SwNumRule& rRul, const SwNumFmt& rFmt, sal_uInt8 nSwLevel );
     984             : 
     985             :     /// Output the numbering table.
     986             :     virtual void WriteNumbering() SAL_OVERRIDE;
     987             : 
     988             :     void OutOverrideListTab();
     989             :     void OutListNamesTab();
     990             : 
     991             :     void RestoreMacroCmds();
     992             : 
     993             :     void InitFontTable();
     994             : 
     995             :     void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
     996             :     void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
     997             : 
     998             : public:
     999             :     virtual void OutputOlst( const SwNumRule& rRule ) SAL_OVERRIDE;
    1000             : 
    1001             :     /// Setup the pA's info.
    1002             :     virtual void SetupSectionPositions( WW8_PdAttrDesc* pA ) SAL_OVERRIDE;
    1003             : 
    1004             :     void Out_SwNumLvl( sal_uInt8 nSwLevel );
    1005             :     void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt,
    1006             :                           sal_uInt8 nSwLevel );
    1007             : 
    1008             :     bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt);
    1009             : 
    1010           0 :     SvxMSExportOLEObjects& GetOLEExp()      { return *pOLEExp; }
    1011           1 :     SwMSConvertControls& GetOCXExp()        { return *pOCXExp; }
    1012           0 :     WW8OleMap& GetOLEMap()                  { return m_aOleMap; }
    1013             :     void ExportDopTypography(WW8DopTypography &rTypo);
    1014             : 
    1015             :     sal_uInt16 AddRedlineAuthor( sal_uInt16 nId );
    1016             : 
    1017             :     void WriteFtnBegin( const SwFmtFtn& rFtn, ww::bytes* pO = 0 );
    1018             :     void WritePostItBegin( ww::bytes* pO = 0 );
    1019             :     const SvxBrushItem* GetCurrentPageBgBrush() const;
    1020             :     SvxBrushItem TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const;
    1021             : 
    1022             :     /// Output all textframes anchored as character for the winword 7- format.
    1023             :     void OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd );
    1024             : 
    1025             :     void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft);
    1026             :     void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
    1027             :     void WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp);
    1028             : 
    1029             :     sal_uInt32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const;
    1030             :     void CreateEscher();
    1031             :     void WriteEscher();
    1032             : 
    1033             :     bool Out_SwNum(const SwTxtNode* pNd);
    1034             : 
    1035             :     /// Write the field
    1036             :     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
    1037             :             const OUString& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) SAL_OVERRIDE;
    1038             : 
    1039             :     void StartCommentOutput( const OUString& rName );
    1040             :     void EndCommentOutput(   const OUString& rName );
    1041             :     void OutGrf(const sw::Frame &rFrame);
    1042             :     bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg,
    1043             :         SvStorageRef xObjStg, OUString &rStorageName, SwOLENode *pOLENd);
    1044             : 
    1045             :     virtual void AppendBookmarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
    1046             :     virtual void AppendBookmark( const OUString& rName, bool bSkip = false ) SAL_OVERRIDE;
    1047             : 
    1048             :     virtual void AppendAnnotationMarks( const SwTxtNode& rNd, sal_Int32 nAktPos, sal_Int32 nLen ) SAL_OVERRIDE;
    1049             : 
    1050             :     virtual void ExportGrfBullet(const SwTxtNode& rNd) SAL_OVERRIDE;
    1051             :     void OutGrfBullets(const sw::Frame &rFrame);
    1052             : 
    1053             :     void MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo);
    1054             : 
    1055             :     void WriteAsStringTable(const ::std::vector<OUString>&, sal_Int32& rfcSttbf,
    1056             :         sal_Int32& rlcbSttbf, sal_uInt16 nExtraLen = 0);
    1057             : 
    1058             :     virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) SAL_OVERRIDE;
    1059             : 
    1060             :     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) SAL_OVERRIDE;
    1061             :     void WriteChar( sal_Unicode c ) SAL_OVERRIDE;
    1062             : 
    1063             :     void OutSwString(const OUString&, sal_Int32 nStt, sal_Int32 nLen,
    1064             :         bool bUnicode, rtl_TextEncoding eChrSet);
    1065             : 
    1066         236 :     WW8_CP Fc2Cp( sal_uLong nFc ) const          { return pPiece->Fc2Cp( nFc ); }
    1067             : 
    1068             :             // some partly static semi-internal function declarations
    1069             : 
    1070          63 :     void OutSprmBytes( sal_uInt8* pBytes, sal_uInt16 nSiz )
    1071          63 :                                 { pO->insert( pO->end(), pBytes, pBytes+nSiz ); }
    1072             : 
    1073          58 :     inline bool IsUnicode() const           { return pPiece->IsUnicode(); }
    1074             : 
    1075             :     virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) SAL_OVERRIDE;
    1076             : 
    1077             :     /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc().
    1078             :     // #i76300#
    1079             :     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
    1080             :                                      const SwNode& rNd,
    1081             :                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
    1082             :                                      const SwPageDesc* pNewPgDesc = 0 ) SAL_OVERRIDE;
    1083             : 
    1084             :     void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine,
    1085             :         sal_uInt16 nDist, sal_uInt16 nSprmNo, sal_uInt16 nSprmNoVer9,
    1086             :         bool bShadow);
    1087             : 
    1088             :     void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow);
    1089             :     void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox );
    1090             :     void Out_CellRangeBorders(const SvxBoxItem * pBox, sal_uInt8 nStart,
    1091             :         sal_uInt8 nLimit);
    1092             :     sal_uInt8 TransCol( const Color& rCol );
    1093             :     bool TransBrush(const Color& rCol, WW8_SHD& rShd);
    1094             :     WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine,
    1095             :         sal_uInt16 nDist, bool bShadow);
    1096             : 
    1097             :     // #i77805# - new return value indicates, if an inherited outline numbering is suppressed
    1098             :     virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) SAL_OVERRIDE;
    1099             : 
    1100          21 :     unsigned int GetHdFtIndex() const { return mnHdFtIndex; }
    1101          24 :     void SetHdFtIndex(unsigned int nHdFtIndex) { mnHdFtIndex = nHdFtIndex; }
    1102          75 :     void IncrementHdFtIndex() { ++mnHdFtIndex; }
    1103             : 
    1104             :     static long GetDTTM( const DateTime& rDT );
    1105             : 
    1106             :     /// Convert the SVX numbering type to id
    1107             :     static sal_uInt8 GetNumId( sal_uInt16 eNumType );
    1108             : 
    1109             :     /// Guess the script (asian/western).
    1110             :     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) SAL_OVERRIDE;
    1111             : 
    1112             :     sal_uInt16 DupNumRuleWithLvlStart(const SwNumRule *pRule,sal_uInt8 nLvl,sal_uInt16 nVal);
    1113             : 
    1114             :     SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const;
    1115             : 
    1116             :     /// Nasty swap for bidi if necessary
    1117             :     bool MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight,
    1118             :         const sw::Frame &rFrmFmt);
    1119             : 
    1120        7087 :     void InsUInt16( sal_uInt16 n )      { SwWW8Writer::InsUInt16( *pO, n ); }
    1121         840 :     void InsUInt32( sal_uInt32 n )      { SwWW8Writer::InsUInt32( *pO, n ); }
    1122             :     void InsAsString16( const OUString& rStr )
    1123             :                         { SwWW8Writer::InsAsString16( *pO, rStr ); }
    1124             :     void InsAsString8( const OUString& rStr, rtl_TextEncoding eCodeSet )
    1125             :                         { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); }
    1126             :     void WriteStringAsPara( const OUString& rTxt, sal_uInt16 nStyleId = 0 );
    1127             : 
    1128             :     /// Setup the exporter.
    1129             :     WW8Export( SwWW8Writer *pWriter,
    1130             :             SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam,
    1131             :             bool bIsWW8, bool bDot );
    1132             :     virtual ~WW8Export();
    1133             : 
    1134             :     virtual void DoComboBox(const OUString &rName,
    1135             :                     const OUString &rHelp,
    1136             :                     const OUString &ToolTip,
    1137             :                     const OUString &rSelected,
    1138             :                     com::sun::star::uno::Sequence<OUString> &rListItems) SAL_OVERRIDE;
    1139             : 
    1140             :     virtual void DoFormText(const SwInputField * pFld) SAL_OVERRIDE;
    1141             : 
    1142             :     void GetCurrentItems(ww::bytes &rItems) const;
    1143             : 
    1144             :     /// Write the data of the form field
    1145             :     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
    1146             :     virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) SAL_OVERRIDE;
    1147             : 
    1148             :     /// Fields.
    1149             :     WW8_WrPlcFld* CurrentFieldPlc() const;
    1150             : 
    1151         846 :     SwWW8Writer& GetWriter() const { return *m_pWriter; }
    1152        2017 :     SvStream& Strm() const { return m_pWriter->Strm(); }
    1153             : 
    1154             :     /// Remember some of the memebers so that we can recurse in WriteText().
    1155             :     virtual void SaveData( sal_uLong nStt, sal_uLong nEnd ) SAL_OVERRIDE;
    1156             : 
    1157             :     /// Restore what was saved in SaveData().
    1158             :     virtual void RestoreData() SAL_OVERRIDE;
    1159             : 
    1160             :     /// Output the actual headers and footers.
    1161             :     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
    1162             :             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
    1163             :         sal_uInt8 nBreakCode) SAL_OVERRIDE;
    1164             : 
    1165             : protected:
    1166             :     /// Output SwGrfNode
    1167             :     virtual void OutputGrfNode( const SwGrfNode& ) SAL_OVERRIDE;
    1168             : 
    1169             :     /// Output SwOLENode
    1170             :     virtual void OutputOLENode( const SwOLENode& ) SAL_OVERRIDE;
    1171             : 
    1172             :     virtual void OutputLinkedOLE( const OUString& ) SAL_OVERRIDE;
    1173             : 
    1174             :     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) SAL_OVERRIDE;
    1175             : 
    1176             : private:
    1177             :     /// No copying.
    1178             :     WW8Export(const WW8Export&);
    1179             :     /// No copying.
    1180             :     WW8Export& operator=(const WW8Export&);
    1181             : };
    1182             : 
    1183             : class WW8_WrPlcSubDoc   // double Plc for Footnotes/Endnotes and Postits
    1184             : {
    1185             : private:
    1186             :     // No copying
    1187             :     WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&);
    1188             :     WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&);
    1189             : protected:
    1190             :     std::vector<WW8_CP> aCps;
    1191             :     std::vector<const void*> aCntnt;                // PTRARR of SwFmtFtn/PostIts/..
    1192             :     std::vector<const SwFrmFmt*> aSpareFmts;        //a backup for aCntnt: if there's no SdrObject, stores the fmt directly here
    1193             :     WW8_WrPlc0* pTxtPos;            // positions of the individual texts
    1194             : 
    1195             :     WW8_WrPlcSubDoc();
    1196             :     virtual ~WW8_WrPlcSubDoc();
    1197             : 
    1198             :     bool WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_CP& rCount );
    1199             :     void WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_FC& rTxtStt,
    1200             :         sal_Int32& rTxtCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const;
    1201             : 
    1202             :     virtual const std::vector<sal_uInt32>* GetShapeIdArr() const;
    1203             : };
    1204             : 
    1205             : // double Plc for Footnotes/Endnotes
    1206          48 : class WW8_WrPlcFtnEdn : public WW8_WrPlcSubDoc
    1207             : {
    1208             : private:
    1209             :     sal_uInt8 nTyp;
    1210             : 
    1211             :     // No copying
    1212             :     WW8_WrPlcFtnEdn(const WW8_WrPlcFtnEdn&);
    1213             :     WW8_WrPlcFtnEdn& operator=(WW8_WrPlcFtnEdn &);
    1214             : public:
    1215          24 :     WW8_WrPlcFtnEdn( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
    1216             : 
    1217             :     bool WriteTxt( WW8Export& rWrt );
    1218             :     void WritePlc( WW8Export& rWrt ) const;
    1219             : 
    1220             :     void Append( WW8_CP nCp, const SwFmtFtn& rFtn );
    1221             : };
    1222             : 
    1223           5 : struct WW8_Annotation
    1224             : {
    1225             :     const OutlinerParaObject* mpRichText;
    1226             :     OUString msSimpleText;
    1227             :     OUString msOwner;
    1228             :     OUString m_sInitials;
    1229             :     DateTime maDateTime;
    1230             :     WW8_CP m_nRangeStart, m_nRangeEnd;
    1231             :     WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
    1232             :     WW8_Annotation(const SwRedlineData* pRedline);
    1233             : };
    1234             : 
    1235             : class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc  // double Plc for Postits
    1236             : {
    1237             : private:
    1238             :     //No copying
    1239             :     WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&);
    1240             :     WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&);
    1241             :     std::set<const SwRedlineData*> maProcessedRedlines;
    1242             : 
    1243             :     std::map<const OUString, WW8_CP> m_aRangeStartPositions;
    1244             : public:
    1245          12 :     WW8_WrPlcAnnotations() {}
    1246             :     virtual ~WW8_WrPlcAnnotations();
    1247             : 
    1248             :     void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp);
    1249             :     void Append( WW8_CP nCp, const SwPostItField* pPostIt );
    1250             :     void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
    1251             :     bool IsNewRedlineComment( const SwRedlineData* pRedLine );
    1252             :     bool WriteTxt( WW8Export& rWrt );
    1253             :     void WritePlc( WW8Export& rWrt ) const;
    1254             : };
    1255             : 
    1256          48 : class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // double Plc for Textboxes
    1257             : {                        // Frame/DrawTextboxes!
    1258             : private:
    1259             :     sal_uInt8 nTyp;
    1260             :     std::vector<sal_uInt32> aShapeIds;        // VARARR of ShapeIds for the SwFrmFmts
    1261             :     virtual const std::vector<sal_uInt32>* GetShapeIdArr() const SAL_OVERRIDE;
    1262             : 
    1263             :     //No copying
    1264             :     WW8_WrPlcTxtBoxes(const WW8_WrPlcTxtBoxes&);
    1265             :     WW8_WrPlcTxtBoxes& operator=(WW8_WrPlcTxtBoxes&);
    1266             : public:
    1267          24 :     WW8_WrPlcTxtBoxes( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
    1268             : 
    1269             :     bool WriteTxt( WW8Export& rWrt );
    1270             :     void WritePlc( WW8Export& rWrt ) const;
    1271             :     void Append( const SdrObject& rObj, sal_uInt32 nShapeId );
    1272             :     void Append( const SwFrmFmt* pFmt, sal_uInt32 nShapeId );
    1273           2 :     sal_uInt16 Count() const { return aCntnt.size(); }
    1274           1 :     sal_uInt16 GetPos( const void* p ) const
    1275             :     {
    1276             :         std::vector<const void*>::const_iterator it
    1277           1 :             = std::find( aCntnt.begin(), aCntnt.end(), p );
    1278           1 :         return it == aCntnt.end() ? USHRT_MAX : it - aCntnt.begin();
    1279             :     }
    1280             : };
    1281             : 
    1282             : // Plc for Chpx and Papx ( incl PN-Plc )
    1283             : typedef boost::ptr_vector<WW8_WrFkp> WW8_WrFkpPtrs;
    1284             : 
    1285             : class WW8_WrPlcPn                   // Plc for Page Numbers
    1286             : {
    1287             : private:
    1288             :     WW8Export& rWrt;
    1289             :     WW8_WrFkpPtrs aFkps;            // PTRARR
    1290             :     sal_uInt16 nFkpStartPage;
    1291             :     ePLCFT ePlc;
    1292             :     bool bWrtWW8;                   // for writer detection
    1293             :     sal_uInt16 nMark;
    1294             : 
    1295             :     //No copying
    1296             :     WW8_WrPlcPn(const WW8_WrPlcPn&);
    1297             :     WW8_WrPlcPn& operator=(const WW8_WrPlcPn&);
    1298             : public:
    1299             :     WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc );
    1300             :     ~WW8_WrPlcPn();
    1301             :     void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const sal_uInt8* pSprms = 0);
    1302             :     void WriteFkps();
    1303             :     void WritePlc();
    1304             :     sal_uInt8 *CopyLastSprms(sal_uInt8 &rLen);
    1305             : };
    1306             : 
    1307             : // class WW8_WrPlc1 is only used for fields
    1308             : class WW8_WrPlc1
    1309             : {
    1310             : private:
    1311             :     std::vector<WW8_CP> aPos;
    1312             :     sal_uInt8* pData;                // content ( structures )
    1313             :     sal_uLong nDataLen;
    1314             :     sal_uInt16 nStructSiz;
    1315             : 
    1316             :     //No copying
    1317             :     WW8_WrPlc1(const WW8_WrPlc1&);
    1318             :     WW8_WrPlc1& operator=(const WW8_WrPlc1&);
    1319             : protected:
    1320         108 :     sal_uInt16 Count() const { return aPos.size(); }
    1321             :     void Write( SvStream& rStrm );
    1322             :     WW8_CP Prev() const;
    1323             : public:
    1324             :     WW8_WrPlc1( sal_uInt16 nStructSz );
    1325             :     ~WW8_WrPlc1();
    1326             :     void Append( WW8_CP nCp, const void* pData );
    1327             :     void Finish( sal_uLong nLastCp, sal_uLong nStartCp );
    1328             : };
    1329             : 
    1330             : // class WW8_WrPlcFld is for fields
    1331          84 : class WW8_WrPlcFld : public WW8_WrPlc1
    1332             : {
    1333             : private:
    1334             :     sal_uInt8 nTxtTyp;
    1335             :     sal_uInt16 nResults;
    1336             : 
    1337             :     //No copying
    1338             :     WW8_WrPlcFld(const WW8_WrPlcFld&);
    1339             :     WW8_WrPlcFld& operator=(const WW8_WrPlcFld&);
    1340             : public:
    1341          84 :     WW8_WrPlcFld( sal_uInt16 nStructSz, sal_uInt8 nTTyp )
    1342          84 :         : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp ), nResults(0)
    1343          84 :     {}
    1344             :     bool Write( WW8Export& rWrt );
    1345           2 :     void ResultAdded() { ++nResults; }
    1346         742 :     sal_uInt16 ResultCount() const { return nResults; }
    1347             : };
    1348             : 
    1349          12 : class WW8_WrMagicTable : public WW8_WrPlc1
    1350             : {
    1351             : private:
    1352             :     //No copying
    1353             :     WW8_WrMagicTable(const WW8_WrMagicTable&);
    1354             :     WW8_WrMagicTable& operator=(const WW8_WrMagicTable&);
    1355             : public:
    1356          12 :     WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);}
    1357             :     void Append( WW8_CP nCp, sal_uLong nData );
    1358             :     bool Write( WW8Export& rWrt );
    1359             : };
    1360             : 
    1361           3 : class GraphicDetails
    1362             : {
    1363             : public:
    1364             :     sw::Frame maFly;                // surrounding FlyFrms
    1365             :     sal_uLong mnPos;                // FilePos of the graphics
    1366             :     sal_uInt16 mnWid;               // Width of the graphics
    1367             :     sal_uInt16 mnHei;               // Height of the graphics
    1368             : 
    1369           1 :     GraphicDetails(const sw::Frame &rFly, sal_uInt16 nWid, sal_uInt16 nHei)
    1370           1 :         : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei)
    1371           1 :     {}
    1372             :     GraphicDetails& operator=(const GraphicDetails& rOther);
    1373             : 
    1374           0 :     bool operator==(const GraphicDetails& rIn) const
    1375             :     {
    1376             :         return (
    1377           0 :                  (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) &&
    1378           0 :                  (maFly.RefersToSameFrameAs(rIn.maFly))
    1379           0 :                );
    1380             :     }
    1381             : };
    1382             : 
    1383             : // class SwWW8WrGrf collects graphics and issues them
    1384          12 : class SwWW8WrGrf
    1385             : {
    1386             : private:
    1387             :     /// for access to the variables
    1388             :     WW8Export& rWrt;
    1389             : 
    1390             :     std::vector<GraphicDetails> maDetails;
    1391             :     typedef std::vector<GraphicDetails>::iterator myiter;
    1392             :     sal_uInt16 mnIdx;       // Index in File-Positionen
    1393             : 
    1394             :     void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly,
    1395             :             sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight,
    1396             :             const SwAttrSet* pAttrSet = 0);
    1397             :     void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem);
    1398             :     void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd,
    1399             :         const sw::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1400             : 
    1401             :     void WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1402             :     void WriteGrfForBullet(SvStream& rStrm,  const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1403             : 
    1404             :     //No copying
    1405             :     SwWW8WrGrf(const SwWW8WrGrf&);
    1406             :     SwWW8WrGrf& operator=(const SwWW8WrGrf&);
    1407             : public:
    1408          12 :     SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {}
    1409             :     void Insert(const sw::Frame &rFly);
    1410             :     void Write();
    1411           1 :     sal_uLong GetFPos()
    1412           1 :         { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
    1413             : };
    1414             : 
    1415             : /** The class MSWordAttrIter is a helper class to build the Fkp.chpx.
    1416             :     This class may be overloaded for output the SwTxtAttrs and the
    1417             :     EditEngineTxtAttrs.
    1418             : */
    1419             : class MSWordAttrIter
    1420             : {
    1421             : private:
    1422             :     MSWordAttrIter* pOld;
    1423             :     //No copying
    1424             :     MSWordAttrIter(const MSWordAttrIter&);
    1425             :     MSWordAttrIter& operator=(const MSWordAttrIter&);
    1426             : protected:
    1427             :     MSWordExportBase& m_rExport;
    1428             : public:
    1429             :     MSWordAttrIter( MSWordExportBase& rExport );
    1430             :     virtual ~MSWordAttrIter();
    1431             : 
    1432             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const = 0;
    1433             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const = 0;
    1434             : };
    1435             : 
    1436             : /// Used to export formatted text associated to drawings.
    1437         196 : class MSWord_SdrAttrIter : public MSWordAttrIter
    1438             : {
    1439             : private:
    1440             :     const EditTextObject* pEditObj;
    1441             :     const SfxItemPool* pEditPool;
    1442             :     std::vector<EECharAttrib> aTxtAtrArr;
    1443             :     std::vector<const EECharAttrib*> aChrTxtAtrArr;
    1444             :     std::vector<rtl_TextEncoding> aChrSetArr;
    1445             :     sal_Int32 nPara;
    1446             :     sal_Int32 nAktSwPos;
    1447             :     sal_Int32 nTmpSwPos;                   // for HasItem()
    1448             :     rtl_TextEncoding eNdChrSet;
    1449             :     sal_uInt16 nScript;
    1450             :     sal_uInt8 mnTyp;
    1451             : 
    1452             :     sal_Int32 SearchNext( sal_Int32 nStartPos );
    1453             :     void SetCharSet(const EECharAttrib& rTxtAttr, bool bStart);
    1454             : 
    1455             :     //No copying
    1456             :     MSWord_SdrAttrIter(const MSWord_SdrAttrIter&);
    1457             :     MSWord_SdrAttrIter& operator=(const MSWord_SdrAttrIter&);
    1458             : public:
    1459             :     MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj,
    1460             :         sal_uInt8 nType );
    1461             :     void NextPara( sal_Int32 nPar );
    1462             :     void OutParaAttr(bool bCharAttr);
    1463             :     void OutEEField(const SfxPoolItem& rHt);
    1464             : 
    1465             :     bool IsTxtAttr(sal_Int32 nSwPos);
    1466             : 
    1467         211 :     void NextPos() { if ( nAktSwPos < SAL_MAX_INT32 ) nAktSwPos = SearchNext( nAktSwPos + 1 ); }
    1468             : 
    1469             :     void OutAttr( sal_Int32 nSwPos );
    1470             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const SAL_OVERRIDE;
    1471             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const SAL_OVERRIDE;
    1472             :     bool OutAttrWithRange(sal_Int32 nPos);
    1473         211 :     sal_Int32 WhereNext() const                { return nAktSwPos; }
    1474             :     rtl_TextEncoding GetNextCharSet() const;
    1475          12 :     rtl_TextEncoding GetNodeCharSet() const     { return eNdChrSet; }
    1476             : };
    1477             : 
    1478             : // class SwWW8AttrIter is a helper for constructing the Fkp.chpx.
    1479             : // Only character attributes are considered; paragraph attributes do not need this treatment.
    1480             : // Die Absatz- und Textattribute des Writers kommen rein, und es wird
    1481             : // mit Where() die naechste Position geliefert, an der sich die Attribute
    1482             : // aendern. IsTxtAtr() sagt, ob sich an der mit Where() gelieferten Position
    1483             : // ein Attribut ohne Ende und mit \xff im Text befindet.
    1484             : // Mit OutAttr() werden die Attribute an der angegebenen SwPos
    1485             : // ausgegeben.
    1486       12070 : class SwWW8AttrIter : public MSWordAttrIter
    1487             : {
    1488             : private:
    1489             :     const SwTxtNode& rNd;
    1490             : 
    1491             :     sw::util::CharRuns maCharRuns;
    1492             :     sw::util::cCharRunIter maCharRunIter;
    1493             : 
    1494             :     rtl_TextEncoding meChrSet;
    1495             :     sal_uInt16 mnScript;
    1496             :     bool mbCharIsRTL;
    1497             : 
    1498             :     const SwRangeRedline* pCurRedline;
    1499             :     sal_Int32 nAktSwPos;
    1500             :     sal_uInt16 nCurRedlinePos;
    1501             : 
    1502             :     bool mbParaIsRTL;
    1503             : 
    1504             :     const SwFmtDrop &mrSwFmtDrop;
    1505             : 
    1506             :     sw::Frames maFlyFrms;     // #i2916#
    1507             :     sw::FrameIter maFlyIter;
    1508             : 
    1509             :     sal_Int32 SearchNext( sal_Int32 nStartPos );
    1510             :     void FieldVanish( const OUString& rTxt );
    1511             : 
    1512             :     void OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool bStart);
    1513             : 
    1514             :     void IterToCurrent();
    1515             : 
    1516             :     //No copying
    1517             :     SwWW8AttrIter(const SwWW8AttrIter&);
    1518             :     SwWW8AttrIter& operator=(const SwWW8AttrIter&);
    1519             : public:
    1520             :     SwWW8AttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd );
    1521             : 
    1522             :     bool IsTxtAttr( sal_Int32 nSwPos );
    1523             :     bool IsRedlineAtEnd( sal_Int32 nPos ) const;
    1524             :     bool IsDropCap( int nSwPos );
    1525             :     bool RequiresImplicitBookmark();
    1526             : 
    1527        7429 :     void NextPos() { if ( nAktSwPos < SAL_MAX_INT32 ) nAktSwPos = SearchNext( nAktSwPos + 1 ); }
    1528             : 
    1529             :     void OutAttr( sal_Int32 nSwPos, bool bRuby = false );
    1530             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const SAL_OVERRIDE;
    1531             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const SAL_OVERRIDE;
    1532             :     int OutAttrWithRange(sal_Int32 nPos);
    1533             :     const SwRedlineData* GetParagraphLevelRedline( );
    1534             :     const SwRedlineData* GetRunLevelRedline( sal_Int32 nPos );
    1535             :     void OutFlys(sal_Int32 nSwPos);
    1536             : 
    1537       15449 :     sal_Int32 WhereNext() const { return nAktSwPos; }
    1538       20279 :     sal_uInt16 GetScript() const { return mnScript; }
    1539        7457 :     bool IsCharRTL() const { return mbCharIsRTL; }
    1540        6616 :     bool IsParaRTL() const { return mbParaIsRTL; }
    1541       13491 :     rtl_TextEncoding GetCharSet() const { return meChrSet; }
    1542             :     OUString GetSnippet(const OUString &rStr, sal_Int32 nAktPos,
    1543             :         sal_Int32 nLen) const;
    1544           0 :     const SwFmtDrop& GetSwFmtDrop() const { return mrSwFmtDrop; }
    1545             : 
    1546             :     bool IsWatermarkFrame();
    1547             : };
    1548             : 
    1549             : /// Class to collect and output the styles table.
    1550             : class MSWordStyles
    1551             : {
    1552             :     MSWordExportBase& m_rExport;
    1553             :     SwFmt** pFmtA; ///< Slot <-> Character and paragraph style array (0 for list styles).
    1554             :     sal_uInt16 nUsedSlots;
    1555             :     bool m_bListStyles; ///< If list styles are requested to be exported as well.
    1556             :     std::map<sal_uInt16, const SwNumRule*> m_aNumRules; ///< Slot <-> List style map.
    1557             : 
    1558             :     /// We need to build style id's for DOCX export; ideally we should roundtrip that, but this is good enough.
    1559             :     std::vector<OString> m_aStyleIds;
    1560             : 
    1561             :     /// Create the style table, called from the constructor.
    1562             :     void BuildStylesTable();
    1563             : 
    1564             :     /// Based on pFmtA, fill in m_aStyleIds with unique, MS-like names.
    1565             :     void BuildStyleIds();
    1566             : 
    1567             :     /// Get slot number during building the style table.
    1568             :     sal_uInt16 BuildGetSlot( const SwFmt& rFmt );
    1569             :     sal_uInt16 BuildGetSlot( const SwNumRule& rNumRule );
    1570             : 
    1571             :     /// Return information about one style.
    1572             :     void GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase, sal_uInt16& nNext );
    1573             : 
    1574             :     /// Outputs attributes of one style.
    1575             :     void WriteProperties( const SwFmt* pFmt, bool bPap, sal_uInt16 nPos, bool bInsDefCharSiz );
    1576             : 
    1577             :     sal_uInt16 GetWWId( const SwFmt& rFmt ) const;
    1578             : 
    1579             :     void SetStyleDefaults( const SwFmt& rFmt, bool bPap );
    1580             : 
    1581             :     /// Outputs one style - called (in a loop) from OutputStylesTable().
    1582             :     void OutputStyle( SwFmt* pFmt, sal_uInt16 nPos );
    1583             :     void OutputStyle( const SwNumRule* pNumRule, sal_uInt16 nPos );
    1584             : 
    1585             :     // No copying
    1586             :     MSWordStyles( const MSWordStyles& );
    1587             :     MSWordStyles& operator=( const MSWordStyles& );
    1588             : 
    1589             : public:
    1590             :     MSWordStyles( MSWordExportBase& rExport, bool bListStyles = false );
    1591             :     ~MSWordStyles();
    1592             : 
    1593             :     /// Output the styles table.
    1594             :     void OutputStylesTable();
    1595             : 
    1596             :     /// Get id of the style (rFmt).
    1597             :     sal_uInt16 GetSlot( const SwFmt& rFmt ) const;
    1598             : 
    1599             :     /// Get styleId of the nId-th style (nId is its position in pFmtA).
    1600             :     OString GetStyleId(sal_uInt16 nId) const;
    1601             : 
    1602        5020 :     const SwFmt* GetSwFmt(sal_uInt16 nId) const { return pFmtA[nId]; }
    1603             :     /// Get numbering rule of the nId-th style
    1604             :     const SwNumRule* GetSwNumRule(sal_uInt16 nId) const;
    1605             : };
    1606             : 
    1607             : #define MSWORD_MAX_STYLES_LIMIT 4091
    1608             : 
    1609             : sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt);
    1610             : // A bit of a bag on the side for now
    1611             : OUString FieldString(ww::eField eIndex);
    1612             : OUString BookmarkToWord(const OUString &rBookmark);
    1613             : 
    1614             : class WW8SHDLong
    1615             : {
    1616             :     sal_uInt32 m_cvFore;
    1617             :     sal_uInt32 m_cvBack;
    1618             :     sal_uInt16 m_ipat;
    1619             : 
    1620             : public:
    1621         254 :     WW8SHDLong() : m_cvFore(0), m_cvBack(0), m_ipat(0) {}
    1622         254 :     virtual ~WW8SHDLong() {}
    1623             : 
    1624             :     void Write(WW8Export & rExport);
    1625         254 :     void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; }
    1626         254 :     void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; }
    1627             :     void setIPat(sal_uInt16 ipat) { m_ipat = ipat; }
    1628             : };
    1629             : 
    1630             : #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
    1631             : 
    1632             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10