LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/filter/ww8 - wrtww8.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 81 97 83.5 %
Date: 2013-07-09 Functions: 77 93 82.8 %
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 _WRTWW8_HXX
      21             : #define _WRTWW8_HXX
      22             : 
      23             : #include <tools/solar.h>        // UINTXX
      24             : #include <tools/gen.hxx>
      25             : #include <editeng/editdata.hxx>
      26             : 
      27             : #include <map>
      28             : #include <vector>
      29             : 
      30             : #include <shellio.hxx>
      31             : #include <wrt_fn.hxx>
      32             : 
      33             : #include "ww8struc.hxx"
      34             : #include "ww8scan.hxx"
      35             : #include "fields.hxx"
      36             : #include "types.hxx"
      37             : #include "writerhelper.hxx"
      38             : #include "../inc/msfilter.hxx"
      39             : #include <expfld.hxx>
      40             : 
      41             : #include <vcl/graph.hxx>
      42             : class SvxBrushItem;
      43             : 
      44             : // einige Forward Deklarationen
      45             : class SwWW8AttrIter;
      46             : namespace msfilter
      47             : {
      48             :     class MSCodec_Std97;
      49             : }
      50             : 
      51             : namespace editeng { class SvxBorderLine; }
      52             : 
      53             : class AttributeOutputBase;
      54             : class DocxAttributeOutput;
      55             : class RtfAttributeOutput;
      56             : class BitmapPalette;
      57             : class SwEscherEx;
      58             : class DateTime;
      59             : class Font;
      60             : class MSWordExportBase;
      61             : class SdrObject;
      62             : class SfxItemSet;
      63             : class SvStream;
      64             : class SvxFontItem;
      65             : class SvxBoxItem;
      66             : class SwAttrSet;
      67             : class SwCharFmt;
      68             : class SwCntntNode;
      69             : class SwField;
      70             : class SwFmt;
      71             : class SwFmtCntnt;
      72             : class SwFmtFtn;
      73             : class SwFrmFmt;
      74             : class SwGrfNode;
      75             : class SwModify;
      76             : class SwNumFmt;
      77             : class SwNumRule;
      78             : class SwNumRuleTbl;
      79             : class SwPageDesc;
      80             : class SwFmtPageDesc;
      81             : class SwOLENode;
      82             : class SwPostItField;
      83             : class SwRedlineData;
      84             : class SwSectionFmt;
      85             : class SwSectionNode;
      86             : class SwTableNode;
      87             : class SwTOXType;
      88             : class SwTxtFmtColl;
      89             : class SwTxtNode;
      90             : class SwWW8WrGrf;
      91             : class SwWW8Writer;
      92             : class MSWordStyles;
      93             : class WW8AttributeOutput;
      94             : class WW8Export;
      95             : class MSWordAttrIter;
      96             : class WW8_WrFkp;
      97             : class WW8_WrPlc0;
      98             : class WW8_WrPlc1;
      99             : class WW8_WrPlcFld;
     100             : class WW8_WrMagicTable;
     101             : class WW8_WrPlcFtnEdn;
     102             : class WW8_WrPlcPn;
     103             : class WW8_WrPlcAnnotations;
     104             : class MSWordSections;
     105             : class WW8_WrPlcTxtBoxes;
     106             : class WW8_WrPct;            // Verwaltung
     107             : class WW8_WrtBookmarks;
     108             : class WW8_WrtRedlineAuthor;
     109             : class SvxMSExportOLEObjects;
     110             : class SwMSConvertControls;
     111             : class WW8_WrPc;
     112             : 
     113             : namespace com { namespace sun { namespace star { namespace embed {
     114             : class XEmbeddedObject;
     115             : } } } }
     116             : typedef std::map<const com::sun::star::embed::XEmbeddedObject*, sal_Int32> WW8OleMap;
     117             : class SvStorageRef;
     118             : struct WW8_PdAttrDesc;
     119             : class SvxBrushItem;
     120             : 
     121             : #include "WW8TableInfo.hxx"
     122             : 
     123             : #define GRF_MAGIC_1 0x12    // 3 magic Bytes fuer PicLocFc-Attribute
     124             : #define GRF_MAGIC_2 0x34
     125             : #define GRF_MAGIC_3 0x56
     126             : #define GRF_MAGIC_321 0x563412L
     127             : 
     128             : #define OLE_PREVIEW_AS_EMF  //If we want to export ole2 previews as emf in ww8+
     129             : 
     130             : typedef sal_uInt8 FieldFlags;
     131             : namespace nsFieldFlags // for InsertField- Method
     132             : {
     133             :     const FieldFlags WRITEFIELD_START         = 0x01;
     134             :     const FieldFlags WRITEFIELD_CMD_START     = 0x02;
     135             :     const FieldFlags WRITEFIELD_CMD_END     = 0x04;
     136             :     const FieldFlags WRITEFIELD_END         = 0x10;
     137             :     const FieldFlags WRITEFIELD_CLOSE         = 0x20;
     138             :     const FieldFlags WRITEFIELD_ALL         = 0xFF;
     139             : }
     140             : 
     141             : enum TxtTypes  //enums for TextTypes
     142             : {
     143             :     TXT_MAINTEXT = 0, /*TXT_FTNEDN = 1,*/ TXT_HDFT = 2, TXT_FTN = 3,
     144             :     TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7
     145             : };
     146             : 
     147             : struct WW8_SepInfo
     148             : {
     149             :     const SwPageDesc* pPageDesc;
     150             :     const SwSectionFmt* pSectionFmt;
     151             :     const SwNode* pPDNd;
     152             :     const SwTxtNode* pNumNd;
     153             :     sal_uLong  nLnNumRestartNo;
     154             :     sal_uInt16 nPgRestartNo;
     155             : 
     156             :     WW8_SepInfo()
     157             :         : pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0), nPgRestartNo(0)
     158             : 
     159             :     {}
     160             : 
     161         102 :     WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt,
     162             :         sal_uLong nLnRestart, sal_uInt16 nPgRestart = 0, const SwNode* pNd = NULL )
     163             :         : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ),
     164         102 :           nLnNumRestartNo( nLnRestart ), nPgRestartNo( nPgRestart )
     165         102 :     {}
     166             : 
     167             :     bool IsProtected() const;
     168             : };
     169             : 
     170             : /// Class to collect and output the sections/headers/footers.
     171             : // Plc fuer PageDescs -> Sepx ( Section Extensions )
     172             : class MSWordSections
     173             : {
     174             : protected:
     175             :     bool mbDocumentIsProtected;
     176             :     std::vector<WW8_SepInfo> aSects;
     177             : 
     178             :     void CheckForFacinPg( WW8Export& rWrt ) const;
     179             :     void WriteOlst( WW8Export& rWrt, const WW8_SepInfo& rSectionInfo );
     180             :     void NeedsDocumentProtected(const WW8_SepInfo &rInfo);
     181             : 
     182             :     //No copy, no assign
     183             :     MSWordSections( const MSWordSections& );
     184             :     MSWordSections& operator=( const MSWordSections& );
     185             : public:
     186             :     MSWordSections( MSWordExportBase& rExport );
     187             :     virtual ~MSWordSections();
     188             : 
     189             :     virtual bool HeaderFooterWritten();
     190             : 
     191             :     void AppendSection( const SwPageDesc* pPd,
     192             :                     const SwSectionFmt* pSectionFmt = 0,
     193             :                     sal_uLong nLnNumRestartNo = 0 );
     194             :     void AppendSection( const SwFmtPageDesc& rPd,
     195             :                     const SwNode& rNd,
     196             :                     const SwSectionFmt* pSectionFmt,
     197             :                     sal_uLong nLnNumRestartNo );
     198             :     void SetNum( const SwTxtNode* pNumNd );
     199             : 
     200             :     /// Number of columns based on the most recent WW8_SepInfo.
     201             :     sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
     202             : 
     203             :     /// Number of columns of the provided WW8_SepInfo.
     204             :     sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const;
     205             : 
     206          19 :     bool DocumentIsProtected() const { return mbDocumentIsProtected; }
     207             : 
     208             :     /// The most recent WW8_SepInfo.
     209             :     const WW8_SepInfo* CurrentSectionInfo();
     210             : 
     211             :     static void SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
     212             :                                   sal_uInt8 nFlag );
     213             :     static void SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFmt& rFmt,
     214             :                                    sal_uInt8 nFlag );
     215             : 
     216             :     /// Should we output borders?
     217             :     static int HasBorderItem( const SwFmt& rFmt );
     218             : };
     219             : 
     220             : class WW8_WrPlcSepx : public MSWordSections
     221             : {
     222             :     std::vector<WW8_CP> aCps;
     223             :     ::std::vector< ::boost::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes;
     224             :     // hack to prevent adding sections in endnotes
     225             :     bool m_bHeaderFooterWritten;
     226             :     WW8_WrPlc0* pTxtPos;        // Pos der einzelnen Header / Footer
     227             : 
     228             :     // No copy, no assign
     229             :     WW8_WrPlcSepx( const WW8_WrPlcSepx& );
     230             :     WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& );
     231             : 
     232             : public:
     233             :     WW8_WrPlcSepx( MSWordExportBase& rExport );
     234             :     ~WW8_WrPlcSepx();
     235             : 
     236             :     virtual bool HeaderFooterWritten(); // override
     237             : 
     238             :     void AppendSep( WW8_CP nStartCp,
     239             :                     const SwPageDesc* pPd,
     240             :                     const SwSectionFmt* pSectionFmt = 0,
     241             :                     sal_uLong nLnNumRestartNo = 0 );
     242             :     void AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPd,
     243             :                     const SwNode& rNd,
     244             :                     const SwSectionFmt* pSectionFmt,
     245             :                     sal_uLong nLnNumRestartNo );
     246           8 :     void Finish( WW8_CP nEndCp ) { aCps.push_back( nEndCp ); }
     247             : 
     248             :     bool WriteKFTxt( WW8Export& rWrt );
     249             :     void WriteSepx( SvStream& rStrm ) const;
     250             :     void WritePlcSed( WW8Export& rWrt ) const;
     251             :     void WritePlcHdd( WW8Export& rWrt ) const;
     252             : 
     253             : private:
     254             :     void WriteFtnEndTxt( WW8Export& rWrt, sal_uLong nCpStt );
     255             : public:
     256             :     void OutHeaderFooter(WW8Export& rWrt, bool bHeader,
     257             :             const SwFmt& rFmt, sal_uLong& rCpPos, sal_uInt8 nHFFlags, sal_uInt8 nFlag,  sal_uInt8 nBreakCode);
     258             : };
     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         604 :     bool IsUnicode() const  { return bIsUni; }
     274             :     WW8_CP Fc2Cp( sal_uLong nFc ) const;
     275             : };
     276             : 
     277             : /// Collects and outputs fonts.
     278        3843 : 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             :     String msFamilyNm;
     285             :     String msAltNm;
     286             :     bool mbAlt;
     287             :     bool mbWrtWW8;
     288             :     FontPitch mePitch;
     289             :     FontFamily meFamily;
     290             :     rtl_TextEncoding meChrSet;
     291             : public:
     292             :     wwFont( const String &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           1 :     OUString GetFamilyName() const { return OUString( msFamilyNm ); }
     298             :     friend bool operator < (const wwFont &r1, const wwFont &r2);
     299             : };
     300             : 
     301          97 : 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          97 :     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          16 :     PlcDrawObj() {}
     363             :     void WritePlc( WW8Export& rWrt ) const;
     364             :     bool Append( WW8Export&, WW8_CP nCp, const sw::Frame& rFmt,
     365             :         const Point& rNdTopLeft );
     366          18 :     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          16 : class MainTxtPlcDrawObj : public PlcDrawObj
     376             : {
     377             : public:
     378           8 :     MainTxtPlcDrawObj() {}
     379             : private:
     380             :     virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
     381             :         sal_uInt32 nLen) const;
     382             :     virtual WW8_CP GetCpOffset(const WW8Fib &) const;
     383             : private:
     384             :     //No copying
     385             :     MainTxtPlcDrawObj(const MainTxtPlcDrawObj&);
     386             :     MainTxtPlcDrawObj& operator=(const MainTxtPlcDrawObj&);
     387             : };
     388             : 
     389          16 : class HdFtPlcDrawObj : public PlcDrawObj
     390             : {
     391             : public:
     392           8 :     HdFtPlcDrawObj() {}
     393             : private:
     394             :     virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
     395             :         sal_uInt32 nLen) const;
     396             :     virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const;
     397             : private:
     398             :     //No copying
     399             :     HdFtPlcDrawObj(const HdFtPlcDrawObj&);
     400             :     HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&);
     401             : };
     402             : 
     403             : typedef ::std::pair<String, 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);
     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             :     String 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< xub_StrLen > 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             :     sal_uInt8 bStyDef : 1;           // should Style be written?
     522             :     sal_uInt8 bBreakBefore : 1;      // Breaks are being written 2 times
     523             :     sal_uInt8 bOutKF : 1;            // Header/Footer texts are being written
     524             :     sal_uInt8 bOutFlyFrmAttrs : 1;   // Frame-attr of Flys are being written
     525             :     sal_uInt8 bOutPageDescs : 1;     ///< PageDescs (section properties) are being written
     526             :     sal_uInt8 bOutFirstPage : 1;     // write Attrset of FirstPageDesc
     527             :     sal_uInt8 bOutTable : 1;         // table is being written
     528             :                                      // ( wird zB bei Flys in Tabelle zurueckgesetzt )
     529             :     sal_uInt8 bOutGrf : 1;           // graphics are being written
     530             :     sal_uInt8 bInWriteEscher : 1;    // in write textboxes
     531             :     sal_uInt8 bStartTOX : 1;         // true: a TOX is startet
     532             :     sal_uInt8 bInWriteTOX : 1;       // true: all content are in a TOX
     533             :     sal_uInt8 bFtnAtTxtEnd : 1;      // true: all FTN at Textend
     534             :     sal_uInt8 bEndAtTxtEnd : 1;      // true: all END at Textend
     535             :     sal_uInt8 bHasHdr : 1;
     536             :     sal_uInt8 bHasFtr : 1;
     537             :     sal_uInt8 bSubstituteBullets : 1; // true: SubstituteBullet() gets called
     538             : 
     539             :     bool mbExportModeRTF;
     540             :     bool mbOutOutlineOnly;   // export outline nodes, only (send outline to clipboard/presentation)
     541             : 
     542             :     SwDoc *pDoc;
     543             :     SwPaM *pCurPam, *pOrigPam;
     544             : 
     545             :     /// Stack to remember the nesting (see MSWordSaveData for more)
     546             :     ::std::stack< MSWordSaveData > maSaveData;
     547             : 
     548             :     /// Used to split the runs according to the bookmarks start and ends
     549             :     typedef std::vector< ::sw::mark::IMark* > IMarkVector;
     550             :     IMarkVector m_rSortedMarksStart;
     551             :     IMarkVector m_rSortedMarksEnd;
     552             : 
     553             : public:
     554             :     /// The main function to export the document.
     555             :     void ExportDocument( bool bWriteAll );
     556             : 
     557             :     /// Iterate through the nodes and call the appropriate OutputNode() on them.
     558             :     void WriteText();
     559             : 
     560             :     /// Return whether cuurently exported node is in table.
     561             :     bool IsInTable() const;
     562             : 
     563             :     /// Set the pCurPam appropriately and call WriteText().
     564             :     ///
     565             :     /// Used to export paragraphs in footnotes/endnotes/etc.
     566             :     void WriteSpecialText( sal_uLong nStart, sal_uLong nEnd, sal_uInt8 nTTyp );
     567             : 
     568             :     /// Export the pool items to attributes (through an attribute output class).
     569             :     void ExportPoolItemsToCHP( sw::PoolItems &rItems, sal_uInt16 nScript );
     570             : 
     571             :     /// Return the numeric id of the numbering rule
     572             :     sal_uInt16 GetId( const SwNumRule& rNumRule );
     573             : 
     574             :     /// Return the numeric id of the style.
     575             :     sal_uInt16 GetId( const SwTxtFmtColl& rColl ) const;
     576             : 
     577             :     /// Return the numeric id of the style.
     578             :     sal_uInt16 GetId( const SwCharFmt& rFmt ) const;
     579             : 
     580             :     sal_uInt16 GetId( const SwTOXType& rTOXType );
     581             : 
     582             :     /// Return the numeric id of the font (and add it to the font list if needed)
     583         953 :     sal_uInt16 GetId( const SvxFontItem& rFont)
     584             :     {
     585         953 :         return maFontHelper.GetId(rFont);
     586             :     }
     587             :     /// @overload
     588           1 :     sal_uInt16 GetId( const wwFont& rFont)
     589             :     {
     590           1 :         return maFontHelper.GetId(rFont);
     591             :     }
     592             : 
     593             :     const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
     594             : 
     595             :     /// Find the reference.
     596             :     bool HasRefToObject( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
     597             : 
     598             :     /// Find the bookmark name.
     599             :     String GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
     600             : 
     601             :     /// Add a bookmark converted to a Word name.
     602             :     void AppendWordBookmark( const String& rName );
     603             : 
     604             :     /// Use OutputItem() on an item set according to the parameters.
     605             :     void OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, sal_uInt16 nScript, bool bExportParentItemSet );
     606             : 
     607             :     short GetDefaultFrameDirection( ) const;
     608             : 
     609             :     /// Right to left?
     610             :     short TrueFrameDirection( const SwFrmFmt& rFlyFmt ) const;
     611             : 
     612             :     /// Right to left?
     613             :     short GetCurrentPageDirection() const;
     614             : 
     615             :     /// In case of numbering restart.
     616             : 
     617             :     /// List is set to restart at a particular value so for export make a
     618             :     /// completely new list based on this one and export that instead,
     619             :     /// which duplicates words behaviour in this respect.
     620             :     sal_uInt16 DuplicateNumRule( const SwNumRule *pRule, sal_uInt8 nLevel, sal_uInt16 nVal );
     621             : 
     622             :     /// Access to the attribute output class.
     623             :     virtual AttributeOutputBase& AttrOutput() const = 0;
     624             : 
     625             :     /// Access to the sections/headers/footres.
     626             :     virtual MSWordSections& Sections() const = 0;
     627             : 
     628             :     /// Determines if the format is expected to support unicode.
     629             :     virtual bool SupportsUnicode() const = 0;
     630             : 
     631             :     /// Used to filter out attributes that can be e.g. written to .doc but not to .docx
     632        1632 :     virtual bool ignoreAttributeForStyles( sal_uInt16 /*nWhich*/ ) const { return false; }
     633             : 
     634             :     /// Guess the script (asian/western).
     635             :     ///
     636             :     /// Sadly word does not have two different sizes for asian font size and
     637             :     /// western font size, it has two different fonts, but not sizes, so we
     638             :     /// have to use our guess as to the script used and disable the export of
     639             :     /// one type. The same occurs for font weight and posture (bold and
     640             :     /// italic).
     641             :     ///
     642             :     /// In addition WW7- has only one character language identifier while WW8+
     643             :     /// has two
     644             :     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) = 0;
     645             : 
     646             :     virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) = 0;
     647             : 
     648             :     virtual void AppendBookmark( const OUString& rName, bool bSkip = false ) = 0;
     649             :     //For i120928,add this interface to export graphic of bullet
     650             :     virtual void ExportGrfBullet(const SwTxtNode& rNd) = 0;
     651             : 
     652             :     // FIXME probably a hack...
     653             :     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0;
     654             : 
     655             :     // FIXME definitely a hack, must not be here - it can't do anything
     656             :     // sensible for docx
     657             :     virtual void WriteChar( sal_Unicode c ) = 0;
     658             : 
     659             :     /// Output attributes.
     660             :     void OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt = false );
     661             : 
     662             :     /// Getter for pISet.
     663         500 :     const SfxItemSet* GetCurItemSet() const { return pISet; }
     664             : 
     665             :     /// Setter for pISet.
     666         390 :     void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; }
     667             : 
     668             :     /// Remember some of the memebers so that we can recurse in WriteText().
     669             :     virtual void SaveData( sal_uLong nStt, sal_uLong nEnd );
     670             : 
     671             :     /// Restore what was saved in SaveData().
     672             :     virtual void RestoreData();
     673             : 
     674             :     /// The return value indicates, if a follow page desc is written.
     675             :     bool OutputFollowPageDesc( const SfxItemSet* pSet,
     676             :                                const SwTxtNode* pNd );
     677             : 
     678             :     /// Write header/footer text.
     679             :     void WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader);
     680             : 
     681             :     /// Format of the section.
     682             :     const SwSectionFmt* GetSectionFormat( const SwNode& rNd ) const;
     683             : 
     684             :     /// Line number of the section start.
     685             :     sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const;
     686             : 
     687             :     /// Start new section.
     688             :     void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd );
     689             : 
     690             :     /// Write section properties.
     691             :     ///
     692             :     /// pA is ignored for docx.
     693             :     void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = NULL );
     694             : 
     695             :     /// Output the numbering table.
     696             :     virtual void WriteNumbering() = 0;
     697             : 
     698             :     /// Write static data of SwNumRule - LSTF
     699             :     void NumberingDefinitions();
     700             : 
     701             :     /// Write all Levels for all SwNumRules - LVLF
     702             :     void AbstractNumberingDefinitions();
     703             : 
     704             :     // Convert the bullet according to the font.
     705             :     void SubstituteBullet( String& rNumStr, rtl_TextEncoding& rChrSet,
     706             :         String& rFontName ) const;
     707             : 
     708             :     /// No-op for the newer WW versions.
     709           0 :     virtual void OutputOlst( const SwNumRule& /*rRule*/ ) {}
     710             : 
     711             :     /// Setup the pA's info.
     712          49 :     virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {}
     713             : 
     714             :     /// Top node of host page when in header/footer.
     715         120 :     void SetHdFtPageRoot( const SwTxtNode *pNd ) { mpTopNodeOfHdFtPage = pNd; }
     716             : 
     717             :     /// Top node of host page when in header/footer.
     718          60 :     const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; }
     719             : 
     720             :     /// Output the actual headers and footers.
     721             :     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
     722             :             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
     723             :         sal_uInt8 nBreakCode) = 0;
     724             : 
     725             :     /// Write the field
     726             :     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
     727             :             const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL ) = 0;
     728             : 
     729             :     /// Write the data of the form field
     730             :     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
     731             :     virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
     732             : 
     733             :     virtual void DoComboBox(const OUString &rName,
     734             :                     const OUString &rHelp,
     735             :                     const OUString &ToolTip,
     736             :                     const OUString &rSelected,
     737             :                     com::sun::star::uno::Sequence<OUString> &rListItems) = 0;
     738             : 
     739             :     virtual void DoFormText(const SwInputField * pFld) = 0;
     740             : 
     741             :     static bool NoPageBreakSection( const SfxItemSet *pSet );
     742             : 
     743             :     // Compute the number format for WW dates
     744             :     bool GetNumberFmt(const SwField& rFld, String& rStr);
     745             : 
     746             :     virtual sal_uLong ReplaceCr( sal_uInt8 nChar ) = 0;
     747             : 
     748             :     const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const;
     749             : 
     750             :     /// Returns the index of a picture bullet, used in numberings.
     751             :     int GetGrfIndex(const SvxBrushItem& rBrush);
     752             : 
     753             : protected:
     754             :     /// Format-dependant part of the actual export.
     755             :     virtual void ExportDocument_Impl() = 0;
     756             : 
     757             :     /// Get the next position in the text node to output
     758             :     virtual xub_StrLen GetNextPos( SwWW8AttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
     759             : 
     760             :     /// Update the information for GetNextPos().
     761             :     virtual void UpdatePosition( SwWW8AttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
     762             : 
     763             :     /// Output SwTxtNode
     764             :     virtual void OutputTextNode( const SwTxtNode& );
     765             : 
     766             :     /// Output SwTableNode
     767             :     void OutputTableNode( const SwTableNode& );
     768             : 
     769             :     /// Setup the chapter fields (maChapterFieldLocs).
     770             :     void GatherChapterFields();
     771             : 
     772             :     void AddLinkTarget( const String& rURL );
     773             :     void CollectOutlineBookmarks( const SwDoc &rDoc );
     774             : 
     775             :     bool SetAktPageDescFromNode(const SwNode &rNd);
     776             :     bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const;
     777             :     bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const;
     778             : 
     779             :     virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) = 0;
     780             : 
     781             :     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
     782             :                                      const SwNode& rNd,
     783             :                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
     784             :                                      const SwPageDesc* pNewPgDesc = 0 ) = 0;
     785             : 
     786             :     /// Return value indicates if an inherited outline numbering is suppressed.
     787             :     virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0;
     788             : 
     789             :     /// Output SwStartNode
     790             :     virtual void OutputStartNode( const SwStartNode& );
     791             : 
     792             :     /// Output SwEndNode
     793             :     virtual void OutputEndNode( const SwEndNode& );
     794             : 
     795             :     /// Output SwGrfNode
     796             :     virtual void OutputGrfNode( const SwGrfNode& ) = 0;
     797             : 
     798             :     /// Output SwOLENode
     799             :     virtual void OutputOLENode( const SwOLENode& ) = 0;
     800             : 
     801             :     virtual void OutputLinkedOLE( const OUString& ) = 0;
     802             : 
     803             : 
     804             :     /// Output SwSectionNode
     805             :     virtual void OutputSectionNode( const SwSectionNode& );
     806             : 
     807             :     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum ) = 0;
     808             : 
     809             :     /// Call the right (virtual) function according to the type of the item.
     810             :     ///
     811             :     /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode()
     812             :     void OutputContentNode( const SwCntntNode& );
     813             : 
     814             :     /// Find the nearest bookmark from the current position.
     815             :     ///
     816             :     /// Returns false when there is no bookmark.
     817             :     bool NearestBookmark( xub_StrLen& rNearest, const xub_StrLen nAktPos, bool bNextPositionOnly );
     818             : 
     819             :     void GetSortedBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos,
     820             :                 xub_StrLen nLen );
     821             : 
     822             :     bool GetBookmarks( const SwTxtNode& rNd, xub_StrLen nStt, xub_StrLen nEnd,
     823             :             IMarkVector& rArr );
     824             : 
     825             :     const NfKeywordTable & GetNfKeywordTable();
     826             : 
     827             :     /// Populates m_vecBulletPic with all the bullet graphics used by numberings.
     828             :     int CollectGrfsOfBullets();
     829             :     /// Write the numbering picture bullets.
     830             :     void BulletDefinitions();
     831             :     std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets
     832             : 
     833             : public:
     834             :     MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam );
     835             :     virtual ~MSWordExportBase();
     836             : 
     837             :     // TODO move as much as possible here from WW8Export! ;-)
     838             : 
     839             :     static void CorrectTabStopInSet( SfxItemSet& rSet, sal_uInt16 nAbsLeft );
     840             : 
     841             : private:
     842             :     /// No copying.
     843             :     MSWordExportBase( const MSWordExportBase& );
     844             :     /// No copying.
     845             :     MSWordExportBase& operator=( const MSWordExportBase& );
     846             : };
     847             : 
     848             : /// The writer class that gets called for the WW8 filter.
     849             : class SwWW8Writer: public StgWriter
     850             : {
     851             : // friends to get access to m_pExport
     852             : // FIXME avoid that, this is probably not what we want
     853             : // (if yes, remove the friends, and provide here a GetExport() method)
     854             : friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt);
     855             : 
     856             :     bool       m_bWrtWW8;
     857             :     WW8Export *m_pExport;
     858             :     SfxMedium *mpMedium;
     859             : 
     860             : public:
     861             :     SwWW8Writer( const String& rFltName, const String& rBaseURL );
     862             :     virtual ~SwWW8Writer();
     863             : 
     864             :     virtual sal_uLong WriteStorage();
     865             :     virtual sal_uLong WriteMedium( SfxMedium& );
     866             : 
     867             :     // TODO most probably we want to be able to get these in
     868             :     // MSExportFilterBase
     869             :     using Writer::getIDocumentSettingAccess;
     870             : 
     871             : public:
     872             :     static void InsUInt16(ww::bytes &rO, sal_uInt16 n);
     873             :     static void InsUInt32(ww::bytes &rO, sal_uInt32 n);
     874             :     static void InsAsString16(ww::bytes &rO, const String& rStr);
     875             :     static void InsAsString8(ww::bytes & O, const String& rStr,
     876             :         rtl_TextEncoding eCodeSet);
     877             : 
     878             :     static sal_uLong FillUntil( SvStream& rStrm, sal_uLong nEndPos = 0 );
     879             :     static void FillCount( SvStream& rStrm, sal_uLong nCount );
     880             : 
     881         208 :     static void WriteShort( SvStream& rStrm, sal_Int16 nVal ) { rStrm << nVal; }
     882             :     static void WriteShort( SvStream& rStrm, sal_uLong nPos, sal_Int16 nVal );
     883             : 
     884         375 :     static void WriteLong( SvStream& rStrm, sal_Int32 nVal ) { rStrm << nVal; }
     885             :     static void WriteLong( SvStream& rStrm, sal_uLong nPos, sal_Int32 nVal );
     886             : 
     887             :     static void WriteString16(SvStream& rStrm, const String& rStr,
     888             :         bool bAddZero);
     889             :     static void WriteString8(SvStream& rStrm, const String& rStr,
     890             :         bool bAddZero, rtl_TextEncoding eCodeSet);
     891             : 
     892             :     static void WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero);
     893             : 
     894             :     bool InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec );
     895             : 
     896             :     using StgWriter::Write;
     897             :     virtual sal_uLong Write( SwPaM&, SfxMedium&, const String* = 0 );
     898             : 
     899             : private:
     900             :     /// No copying.
     901             :     SwWW8Writer(const SwWW8Writer&);
     902             :     /// No copying.
     903             :     SwWW8Writer& operator=(const SwWW8Writer&);
     904             : };
     905             : 
     906             : /// Exporter of the binary Word file formats.
     907             : class WW8Export : public MSWordExportBase
     908             : {
     909             : public:
     910             :     ww::bytes* pO;                       ///< Buffer
     911             : 
     912             :     SvStream *pTableStrm, *pDataStrm;   ///< Streams for WW97 Export
     913             : 
     914             :     WW8Fib* pFib;                       ///< File Information Block
     915             :     WW8Dop* pDop;                       ///< DOcument Properties
     916             :     WW8_WrPlcFtnEdn *pFtn;              ///< Footnotes - structure to remember them, and output
     917             :     WW8_WrPlcFtnEdn *pEdn;              ///< Endnotes - structure to remember them, and output
     918             :     WW8_WrPlcSepx* pSepx;               ///< Sections/headers/footers
     919             : 
     920             :     sal_uInt8 bWrtWW8 : 1;                   ///< Write WW95 (false) or WW97 (true) file format
     921             : 
     922             : protected:
     923             :     SwWW8Writer        *m_pWriter;      ///< Pointer to the writer
     924             :     WW8AttributeOutput *m_pAttrOutput;  ///< Converting attributes to stream data
     925             : 
     926             : private:
     927             :     SvStorageRef       xEscherStg;      /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj
     928             : 
     929             : public:
     930             :     /// Access to the attribute output class.
     931             :     virtual AttributeOutputBase& AttrOutput() const;
     932             : 
     933             :     /// Access to the sections/headers/footres.
     934             :     virtual MSWordSections& Sections() const;
     935             : 
     936             :     /// False for WW6, true for WW8.
     937         930 :     virtual bool SupportsUnicode() const { return bWrtWW8; }
     938             : 
     939             : private:
     940             :     /// Format-dependant part of the actual export.
     941             :     virtual void ExportDocument_Impl();
     942             : 
     943             :     void PrepareStorage();
     944             :     void WriteFkpPlcUsw();
     945             :     void WriteMainText();
     946             :     void StoreDoc1();
     947             :     void Out_WwNumLvl( sal_uInt8 nWwLevel );
     948             :     void BuildAnlvBulletBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen,
     949             :                               const SwNumFmt& rFmt );
     950             :     static void BuildAnlvBase( WW8_ANLV& rAnlv, sal_uInt8*& rpCh, sal_uInt16& rCharLen,
     951             :                    const SwNumRule& rRul, const SwNumFmt& rFmt, sal_uInt8 nSwLevel );
     952             : 
     953             :     void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine,
     954             :         sal_uInt16 nDist, sal_uInt16 nSprmNo, bool bShadow);
     955             : 
     956             :     /// Output the numbering table.
     957             :     virtual void WriteNumbering();
     958             : 
     959             :     void OutOverrideListTab();
     960             :     void OutListNamesTab();
     961             : 
     962             :     void RestoreMacroCmds();
     963             : 
     964             :     void InitFontTable();
     965             : 
     966             :     void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
     967             :     void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
     968             : 
     969             : public:
     970             :     virtual void OutputOlst( const SwNumRule& rRule );
     971             : 
     972             :     /// Setup the pA's info.
     973             :     virtual void SetupSectionPositions( WW8_PdAttrDesc* pA );
     974             : 
     975             :     void Out_SwNumLvl( sal_uInt8 nSwLevel );
     976             :     void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt,
     977             :                           sal_uInt8 nSwLevel );
     978             : 
     979             :     bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt);
     980             : 
     981           0 :     SvxMSExportOLEObjects& GetOLEExp()      { return *pOLEExp; }
     982           1 :     SwMSConvertControls& GetOCXExp()        { return *pOCXExp; }
     983           0 :     WW8OleMap& GetOLEMap()                  { return m_aOleMap; }
     984             :     void ExportDopTypography(WW8DopTypography &rTypo);
     985             : 
     986             :     sal_uInt16 AddRedlineAuthor( sal_uInt16 nId );
     987             : 
     988             :     void WriteFtnBegin( const SwFmtFtn& rFtn, ww::bytes* pO = 0 );
     989             :     void WritePostItBegin( ww::bytes* pO = 0 );
     990             :     const SvxBrushItem* GetCurrentPageBgBrush() const;
     991             :     SvxBrushItem TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const;
     992             : 
     993             :     /// Output all textframes anchored as character for the winword 7- format.
     994             :     void OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd );
     995             : 
     996             :     void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft);
     997             :     void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
     998             :     void WriteSdrTextObj(const SdrObject& rObj, sal_uInt8 nTyp);
     999             : 
    1000             :     sal_uInt32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const;
    1001             :     void CreateEscher();
    1002             :     void WriteEscher();
    1003             : 
    1004             :     bool Out_SwNum(const SwTxtNode* pNd);
    1005             : 
    1006             :     /// Write the field
    1007             :     virtual void OutputField( const SwField* pFld, ww::eField eFldType,
    1008             :             const String& rFldCmd, sal_uInt8 nMode = nsFieldFlags::WRITEFIELD_ALL );
    1009             : 
    1010             :     void StartCommentOutput( const String& rName );
    1011             :     void EndCommentOutput(   const String& rName );
    1012             :     void OutGrf(const sw::Frame &rFrame);
    1013             :     bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg,
    1014             :         SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd);
    1015             : 
    1016             :     virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen );
    1017             :     virtual void AppendBookmark( const OUString& rName, bool bSkip = false );
    1018             : 
    1019             :     virtual void ExportGrfBullet(const SwTxtNode& rNd);
    1020             :     void OutGrfBullets(const sw::Frame &rFrame);
    1021             : 
    1022             :     void MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo);
    1023             : 
    1024             :     void WriteAsStringTable(const ::std::vector<OUString>&, sal_Int32& rfcSttbf,
    1025             :         sal_Int32& rlcbSttbf, sal_uInt16 nExtraLen = 0);
    1026             : 
    1027             :     virtual sal_uLong ReplaceCr( sal_uInt8 nChar );
    1028             : 
    1029             :     virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() );
    1030             :     void WriteChar( sal_Unicode c );
    1031             : 
    1032             :     void OutSwString(const String&, xub_StrLen nStt, xub_StrLen nLen,
    1033             :         bool bUnicode, rtl_TextEncoding eChrSet);
    1034             : 
    1035         164 :     WW8_CP Fc2Cp( sal_uLong nFc ) const          { return pPiece->Fc2Cp( nFc ); }
    1036             : 
    1037             :             // some partly static semi-internal function declarations
    1038             : 
    1039          63 :     void OutSprmBytes( sal_uInt8* pBytes, sal_uInt16 nSiz )
    1040          63 :                                 { pO->insert( pO->end(), pBytes, pBytes+nSiz ); }
    1041             : 
    1042          25 :     inline bool IsUnicode() const           { return pPiece->IsUnicode(); }
    1043             : 
    1044             :     virtual void SectionBreaksAndFrames( const SwTxtNode& rNode );
    1045             : 
    1046             :     /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc().
    1047             :     // #i76300#
    1048             :     virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
    1049             :                                      const SwNode& rNd,
    1050             :                                      const SwFmtPageDesc* pNewPgDescFmt = 0,
    1051             :                                      const SwPageDesc* pNewPgDesc = 0 );
    1052             : 
    1053             :     void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow);
    1054             :     void Out_SwFmtTableBox( ww::bytes& rO, const SvxBoxItem * rBox );
    1055             :     sal_uInt8 TransCol( const Color& rCol );
    1056             :     bool TransBrush(const Color& rCol, WW8_SHD& rShd);
    1057             :     WW8_BRC TranslateBorderLine(const ::editeng::SvxBorderLine& pLine,
    1058             :         sal_uInt16 nDist, bool bShadow);
    1059             : 
    1060             :     // #i77805# - new return value indicates, if an inherited outline numbering is suppressed
    1061             :     virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt);
    1062             : 
    1063          17 :     unsigned int GetHdFtIndex() const { return mnHdFtIndex; }
    1064          16 :     void SetHdFtIndex(unsigned int nHdFtIndex) { mnHdFtIndex = nHdFtIndex; }
    1065          55 :     void IncrementHdFtIndex() { ++mnHdFtIndex; }
    1066             : 
    1067             :     static long GetDTTM( const DateTime& rDT );
    1068             : 
    1069             :     /// Convert the SVX numbering type to id
    1070             :     static sal_uInt8 GetNumId( sal_uInt16 eNumType );
    1071             : 
    1072             :     /// Guess the script (asian/western).
    1073             :     virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich );
    1074             : 
    1075             :     sal_uInt16 DupNumRuleWithLvlStart(const SwNumRule *pRule,sal_uInt8 nLvl,sal_uInt16 nVal);
    1076             : 
    1077             :     SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const;
    1078             : 
    1079             :     /// Nasty swap for bidi if necessary
    1080             :     bool MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight,
    1081             :         const sw::Frame &rFrmFmt);
    1082             : 
    1083        5936 :     void InsUInt16( sal_uInt16 n )      { SwWW8Writer::InsUInt16( *pO, n ); }
    1084         775 :     void InsUInt32( sal_uInt32 n )      { SwWW8Writer::InsUInt32( *pO, n ); }
    1085             :     void InsAsString16( const String& rStr )
    1086             :                         { SwWW8Writer::InsAsString16( *pO, rStr ); }
    1087             :     void InsAsString8( const String& rStr, rtl_TextEncoding eCodeSet )
    1088             :                         { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); }
    1089             :     void WriteStringAsPara( const String& rTxt, sal_uInt16 nStyleId = 0 );
    1090             : 
    1091             :     /// Setup the exporter.
    1092             :     WW8Export( SwWW8Writer *pWriter,
    1093             :             SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam,
    1094             :             bool bIsWW8 );
    1095             :     virtual ~WW8Export();
    1096             : 
    1097             :     virtual void DoComboBox(const OUString &rName,
    1098             :                     const OUString &rHelp,
    1099             :                     const OUString &ToolTip,
    1100             :                     const OUString &rSelected,
    1101             :                     com::sun::star::uno::Sequence<OUString> &rListItems);
    1102             : 
    1103             :     virtual void DoFormText(const SwInputField * pFld);
    1104             : 
    1105             :     void GetCurrentItems(ww::bytes &rItems) const;
    1106             : 
    1107             :     /// Write the data of the form field
    1108             :     virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
    1109             :     virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark );
    1110             : 
    1111             :     /// Fields.
    1112             :     WW8_WrPlcFld* CurrentFieldPlc() const;
    1113             : 
    1114         715 :     SwWW8Writer& GetWriter() const { return *m_pWriter; }
    1115        1673 :     SvStream& Strm() const { return m_pWriter->Strm(); }
    1116             : 
    1117             :     /// Remember some of the memebers so that we can recurse in WriteText().
    1118             :     virtual void SaveData( sal_uLong nStt, sal_uLong nEnd );
    1119             : 
    1120             :     /// Restore what was saved in SaveData().
    1121             :     virtual void RestoreData();
    1122             : 
    1123             :     /// Output the actual headers and footers.
    1124             :     virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
    1125             :             const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
    1126             :         sal_uInt8 nBreakCode);
    1127             : 
    1128             : protected:
    1129             :     /// Output SwGrfNode
    1130             :     virtual void OutputGrfNode( const SwGrfNode& );
    1131             : 
    1132             :     /// Output SwOLENode
    1133             :     virtual void OutputOLENode( const SwOLENode& );
    1134             : 
    1135             :     virtual void OutputLinkedOLE( const OUString& );
    1136             : 
    1137             :     virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, sal_uLong nLnNum );
    1138             : 
    1139             : private:
    1140             :     /// No copying.
    1141             :     WW8Export(const WW8Export&);
    1142             :     /// No copying.
    1143             :     WW8Export& operator=(const WW8Export&);
    1144             : };
    1145             : 
    1146             : class WW8_WrPlcSubDoc   // double Plc for Footnotes/Endnotes and Postits
    1147             : {
    1148             : private:
    1149             :     // No copying
    1150             :     WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&);
    1151             :     WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&);
    1152             : protected:
    1153             :     std::vector<WW8_CP> aCps;
    1154             :     std::vector<const void*> aCntnt;                // PTRARR of SwFmtFtn/PostIts/..
    1155             :     std::vector<const SwFrmFmt*> aSpareFmts;        //a backup for aCntnt: if there's no SdrObject, stores the fmt directly here
    1156             :     WW8_WrPlc0* pTxtPos;            // positions of the individual texts
    1157             : 
    1158             :     WW8_WrPlcSubDoc();
    1159             :     virtual ~WW8_WrPlcSubDoc();
    1160             : 
    1161             :     bool WriteGenericTxt( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_CP& rCount );
    1162             :     void WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_FC& rTxtStt,
    1163             :         sal_Int32& rTxtCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const;
    1164             : 
    1165             :     virtual const std::vector<sal_uInt32>* GetShapeIdArr() const;
    1166             : };
    1167             : 
    1168             : // double Plc for Footnotes/Endnotes
    1169          32 : class WW8_WrPlcFtnEdn : public WW8_WrPlcSubDoc
    1170             : {
    1171             : private:
    1172             :     sal_uInt8 nTyp;
    1173             : 
    1174             :     // No copying
    1175             :     WW8_WrPlcFtnEdn(const WW8_WrPlcFtnEdn&);
    1176             :     WW8_WrPlcFtnEdn& operator=(WW8_WrPlcFtnEdn &);
    1177             : public:
    1178          16 :     WW8_WrPlcFtnEdn( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
    1179             : 
    1180             :     bool WriteTxt( WW8Export& rWrt );
    1181             :     void WritePlc( WW8Export& rWrt ) const;
    1182             : 
    1183             :     void Append( WW8_CP nCp, const SwFmtFtn& rFtn );
    1184             : };
    1185             : 
    1186           0 : struct WW8_Annotation
    1187             : {
    1188             :     const OutlinerParaObject* mpRichText;
    1189             :     String msSimpleText;
    1190             :     String msOwner;
    1191             :     DateTime maDateTime;
    1192             :     WW8_Annotation(const SwPostItField* pPostIt);
    1193             :     WW8_Annotation(const SwRedlineData* pRedline);
    1194             : };
    1195             : 
    1196             : class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc  // double Plc for Postits
    1197             : {
    1198             : private:
    1199             :     //No copying
    1200             :     WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&);
    1201             :     WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&);
    1202             :     std::set<const SwRedlineData*> maProcessedRedlines;
    1203             : public:
    1204           8 :     WW8_WrPlcAnnotations() {}
    1205             :     ~WW8_WrPlcAnnotations();
    1206             : 
    1207             :     void Append( WW8_CP nCp, const SwPostItField* pPostIt );
    1208             :     void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
    1209             :     bool IsNewRedlineComment( const SwRedlineData* pRedLine );
    1210             :     bool WriteTxt( WW8Export& rWrt );
    1211             :     void WritePlc( WW8Export& rWrt ) const;
    1212             : };
    1213             : 
    1214          32 : class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // double Plc for Textboxes
    1215             : {                        // Frame/DrawTextboxes!
    1216             : private:
    1217             :     sal_uInt8 nTyp;
    1218             :     std::vector<sal_uInt32> aShapeIds;        // VARARR of ShapeIds for the SwFrmFmts
    1219             :     virtual const std::vector<sal_uInt32>* GetShapeIdArr() const;
    1220             : 
    1221             :     //No copying
    1222             :     WW8_WrPlcTxtBoxes(const WW8_WrPlcTxtBoxes&);
    1223             :     WW8_WrPlcTxtBoxes& operator=(WW8_WrPlcTxtBoxes&);
    1224             : public:
    1225          16 :     WW8_WrPlcTxtBoxes( sal_uInt8 nTTyp ) : nTyp( nTTyp ) {}
    1226             : 
    1227             :     bool WriteTxt( WW8Export& rWrt );
    1228             :     void WritePlc( WW8Export& rWrt ) const;
    1229             :     void Append( const SdrObject& rObj, sal_uInt32 nShapeId );
    1230             :     void Append( const SwFrmFmt* pFmt, sal_uInt32 nShapeId );
    1231           2 :     sal_uInt16 Count() const { return aCntnt.size(); }
    1232           1 :     sal_uInt16 GetPos( const void* p ) const
    1233             :     {
    1234             :         std::vector<const void*>::const_iterator it
    1235           1 :             = std::find( aCntnt.begin(), aCntnt.end(), p );
    1236           1 :         return it == aCntnt.end() ? USHRT_MAX : it - aCntnt.begin();
    1237             :     }
    1238             : };
    1239             : 
    1240             : // Plc for Chpx and Papx ( incl PN-Plc )
    1241             : typedef boost::ptr_vector<WW8_WrFkp> WW8_WrFkpPtrs;
    1242             : 
    1243             : class WW8_WrPlcPn                   // Plc for Page Numbers
    1244             : {
    1245             : private:
    1246             :     WW8Export& rWrt;
    1247             :     WW8_WrFkpPtrs aFkps;            // PTRARR
    1248             :     sal_uInt16 nFkpStartPage;
    1249             :     ePLCFT ePlc;
    1250             :     bool bWrtWW8;                   // for writer detection
    1251             :     sal_uInt16 nMark;
    1252             : 
    1253             :     //No copying
    1254             :     WW8_WrPlcPn(const WW8_WrPlcPn&);
    1255             :     WW8_WrPlcPn& operator=(const WW8_WrPlcPn&);
    1256             : public:
    1257             :     WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc );
    1258             :     ~WW8_WrPlcPn();
    1259             :     void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const sal_uInt8* pSprms = 0);
    1260             :     void WriteFkps();
    1261             :     void WritePlc();
    1262             :     sal_uInt8 *CopyLastSprms(sal_uInt8 &rLen);
    1263             : };
    1264             : 
    1265             : // class WW8_WrPlc1 is only used for fields
    1266             : class WW8_WrPlc1
    1267             : {
    1268             : private:
    1269             :     std::vector<WW8_CP> aPos;
    1270             :     sal_uInt8* pData;                // content ( structures )
    1271             :     sal_uLong nDataLen;
    1272             :     sal_uInt16 nStructSiz;
    1273             : 
    1274             :     //No copying
    1275             :     WW8_WrPlc1(const WW8_WrPlc1&);
    1276             :     WW8_WrPlc1& operator=(const WW8_WrPlc1&);
    1277             : protected:
    1278          72 :     sal_uInt16 Count() const { return aPos.size(); }
    1279             :     void Write( SvStream& rStrm );
    1280             :     WW8_CP Prev() const;
    1281             : public:
    1282             :     WW8_WrPlc1( sal_uInt16 nStructSz );
    1283             :     ~WW8_WrPlc1();
    1284             :     void Append( WW8_CP nCp, const void* pData );
    1285             :     void Finish( sal_uLong nLastCp, sal_uLong nStartCp );
    1286             : };
    1287             : 
    1288             : // class WW8_WrPlcFld is for fields
    1289          56 : class WW8_WrPlcFld : public WW8_WrPlc1
    1290             : {
    1291             : private:
    1292             :     sal_uInt8 nTxtTyp;
    1293             :     sal_uInt16 nResults;
    1294             : 
    1295             :     //No copying
    1296             :     WW8_WrPlcFld(const WW8_WrPlcFld&);
    1297             :     WW8_WrPlcFld& operator=(const WW8_WrPlcFld&);
    1298             : public:
    1299          56 :     WW8_WrPlcFld( sal_uInt16 nStructSz, sal_uInt8 nTTyp )
    1300          56 :         : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp ), nResults(0)
    1301          56 :     {}
    1302             :     bool Write( WW8Export& rWrt );
    1303           2 :     void ResultAdded() { ++nResults; }
    1304         648 :     sal_uInt16 ResultCount() const { return nResults; }
    1305             : };
    1306             : 
    1307           8 : class WW8_WrMagicTable : public WW8_WrPlc1
    1308             : {
    1309             : private:
    1310             :     //No copying
    1311             :     WW8_WrMagicTable(const WW8_WrMagicTable&);
    1312             :     WW8_WrMagicTable& operator=(const WW8_WrMagicTable&);
    1313             : public:
    1314           8 :     WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);}
    1315             :     void Append( WW8_CP nCp, sal_uLong nData );
    1316             :     bool Write( WW8Export& rWrt );
    1317             : };
    1318             : 
    1319           0 : class GraphicDetails
    1320             : {
    1321             : public:
    1322             :     sw::Frame maFly;                // surrounding FlyFrms
    1323             :     sal_uLong mnPos;                // FilePos of the graphics
    1324             :     sal_uInt16 mnWid;               // Width of the graphics
    1325             :     sal_uInt16 mnHei;               // Height of the graphics
    1326             : 
    1327           0 :     GraphicDetails(const sw::Frame &rFly, sal_uInt16 nWid, sal_uInt16 nHei)
    1328           0 :         : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei)
    1329           0 :     {}
    1330             :     GraphicDetails& operator=(const GraphicDetails& rOther);
    1331             : 
    1332           0 :     bool operator==(const GraphicDetails& rIn) const
    1333             :     {
    1334             :         return (
    1335           0 :                  (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) &&
    1336           0 :                  (maFly.RefersToSameFrameAs(rIn.maFly))
    1337           0 :                );
    1338             :     }
    1339             : };
    1340             : 
    1341             : // class SwWW8WrGrf collects graphics and issues them
    1342           8 : class SwWW8WrGrf
    1343             : {
    1344             : private:
    1345             :     /// for access to the variables
    1346             :     WW8Export& rWrt;
    1347             : 
    1348             :     std::vector<GraphicDetails> maDetails;
    1349             :     typedef std::vector<GraphicDetails>::iterator myiter;
    1350             :     sal_uInt16 mnIdx;       // Index in File-Positionen
    1351             : 
    1352             :     void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly,
    1353             :             sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight,
    1354             :             const SwAttrSet* pAttrSet = 0);
    1355             :     void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem);
    1356             :     void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd,
    1357             :         const sw::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1358             : 
    1359             :     void WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1360             :     void WriteGrfForBullet(SvStream& rStrm,  const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight);
    1361             : 
    1362             :     //No copying
    1363             :     SwWW8WrGrf(const SwWW8WrGrf&);
    1364             :     SwWW8WrGrf& operator=(const SwWW8WrGrf&);
    1365             : public:
    1366           8 :     SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {}
    1367             :     void Insert(const sw::Frame &rFly);
    1368             :     void Write();
    1369           0 :     sal_uLong GetFPos()
    1370           0 :         { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
    1371             : };
    1372             : 
    1373             : /** The class MSWordAttrIter is a helper class to build the Fkp.chpx.
    1374             :     This class may be overloaded for output the SwTxtAttrs and the
    1375             :     EditEngineTxtAttrs.
    1376             : */
    1377             : class MSWordAttrIter
    1378             : {
    1379             : private:
    1380             :     MSWordAttrIter* pOld;
    1381             :     //No copying
    1382             :     MSWordAttrIter(const MSWordAttrIter&);
    1383             :     MSWordAttrIter& operator=(const MSWordAttrIter&);
    1384             : protected:
    1385             :     MSWordExportBase& m_rExport;
    1386             : public:
    1387             :     MSWordAttrIter( MSWordExportBase& rExport );
    1388             :     virtual ~MSWordAttrIter();
    1389             : 
    1390             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const = 0;
    1391             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const = 0;
    1392             : };
    1393             : 
    1394             : /// Used to export formatted text associated to drawings.
    1395           1 : class MSWord_SdrAttrIter : public MSWordAttrIter
    1396             : {
    1397             : private:
    1398             :     const EditTextObject* pEditObj;
    1399             :     const SfxItemPool* pEditPool;
    1400             :     std::vector<EECharAttrib> aTxtAtrArr;
    1401             :     std::vector<const EECharAttrib*> aChrTxtAtrArr;
    1402             :     std::vector<rtl_TextEncoding> aChrSetArr;
    1403             :     sal_Int32 nPara;
    1404             :     xub_StrLen nAktSwPos;
    1405             :     xub_StrLen nTmpSwPos;                   // for HasItem()
    1406             :     rtl_TextEncoding eNdChrSet;
    1407             :     sal_uInt16 nScript;
    1408             :     sal_uInt8 mnTyp;
    1409             : 
    1410             :     xub_StrLen SearchNext( xub_StrLen nStartPos );
    1411             :     void SetCharSet(const EECharAttrib& rTxtAttr, bool bStart);
    1412             : 
    1413             :     //No copying
    1414             :     MSWord_SdrAttrIter(const MSWord_SdrAttrIter&);
    1415             :     MSWord_SdrAttrIter& operator=(const MSWord_SdrAttrIter&);
    1416             : public:
    1417             :     MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj,
    1418             :         sal_uInt8 nType );
    1419             :     void NextPara( sal_Int32 nPar );
    1420             :     void OutParaAttr(bool bCharAttr);
    1421             :     void OutEEField(const SfxPoolItem& rHt);
    1422             : 
    1423             :     bool IsTxtAttr(xub_StrLen nSwPos);
    1424             : 
    1425           1 :     void NextPos() { if ( nAktSwPos < STRING_NOTFOUND ) nAktSwPos = SearchNext( nAktSwPos + 1 ); }
    1426             : 
    1427             :     void OutAttr( xub_StrLen nSwPos );
    1428             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const;
    1429             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
    1430             :     bool OutAttrWithRange(xub_StrLen nPos);
    1431           1 :     xub_StrLen WhereNext() const                { return nAktSwPos; }
    1432             :     rtl_TextEncoding GetNextCharSet() const;
    1433           1 :     rtl_TextEncoding GetNodeCharSet() const     { return eNdChrSet; }
    1434             : };
    1435             : 
    1436             : // class SwWW8AttrIter is a helper for constructing the Fkp.chpx.
    1437             : // Only character attributes are considered; paragraph attributes do not need this treatment.
    1438             : // Die Absatz- und Textattribute des Writers kommen rein, und es wird
    1439             : // mit Where() die naechste Position geliefert, an der sich die Attribute
    1440             : // aendern. IsTxtAtr() sagt, ob sich an der mit Where() gelieferten Position
    1441             : // ein Attribut ohne Ende und mit \xff im Text befindet.
    1442             : // Mit OutAttr() werden die Attribute an der angegebenen SwPos
    1443             : // ausgegeben.
    1444         622 : class SwWW8AttrIter : public MSWordAttrIter
    1445             : {
    1446             : private:
    1447             :     const SwTxtNode& rNd;
    1448             : 
    1449             :     sw::util::CharRuns maCharRuns;
    1450             :     sw::util::cCharRunIter maCharRunIter;
    1451             : 
    1452             :     rtl_TextEncoding meChrSet;
    1453             :     sal_uInt16 mnScript;
    1454             :     bool mbCharIsRTL;
    1455             : 
    1456             :     const SwRedline* pCurRedline;
    1457             :     xub_StrLen nAktSwPos;
    1458             :     sal_uInt16 nCurRedlinePos;
    1459             : 
    1460             :     bool mbParaIsRTL;
    1461             : 
    1462             :     const SwFmtDrop &mrSwFmtDrop;
    1463             : 
    1464             :     sw::Frames maFlyFrms;     // #i2916#
    1465             :     sw::FrameIter maFlyIter;
    1466             : 
    1467             :     xub_StrLen SearchNext( xub_StrLen nStartPos );
    1468             :     void FieldVanish( const String& rTxt );
    1469             : 
    1470             :     void OutSwFmtRefMark(const SwFmtRefMark& rAttr, bool bStart);
    1471             : 
    1472             :     void IterToCurrent();
    1473             : 
    1474             :     //No copying
    1475             :     SwWW8AttrIter(const SwWW8AttrIter&);
    1476             :     SwWW8AttrIter& operator=(const SwWW8AttrIter&);
    1477             : public:
    1478             :     SwWW8AttrIter( MSWordExportBase& rWr, const SwTxtNode& rNd );
    1479             : 
    1480             :     bool IsTxtAttr( xub_StrLen nSwPos );
    1481             :     bool IsRedlineAtEnd( xub_StrLen nPos ) const;
    1482             :     bool IsDropCap( int nSwPos );
    1483             :     bool RequiresImplicitBookmark();
    1484             : 
    1485         725 :     void NextPos() { if ( nAktSwPos < STRING_NOTFOUND ) nAktSwPos = SearchNext( nAktSwPos + 1 ); }
    1486             : 
    1487             :     void OutAttr( xub_StrLen nSwPos, bool bRuby = false );
    1488             :     virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const;
    1489             :     virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
    1490             :     int OutAttrWithRange(xub_StrLen nPos);
    1491             :     const SwRedlineData* GetRedline( xub_StrLen nPos );
    1492             :     void OutFlys(xub_StrLen nSwPos);
    1493             : 
    1494        1459 :     xub_StrLen WhereNext() const    { return nAktSwPos; }
    1495        1970 :     sal_uInt16 GetScript() const { return mnScript; }
    1496         727 :     bool IsCharRTL() const { return mbCharIsRTL; }
    1497         767 :     bool IsParaRTL() const { return mbParaIsRTL; }
    1498        1349 :     rtl_TextEncoding GetCharSet() const { return meChrSet; }
    1499             :     String GetSnippet(const String &rStr, xub_StrLen nAktPos,
    1500             :         xub_StrLen nLen) const;
    1501           0 :     const SwFmtDrop& GetSwFmtDrop() const { return mrSwFmtDrop; }
    1502             : };
    1503             : 
    1504             : /// Class to collect and output the styles table.
    1505             : class MSWordStyles
    1506             : {
    1507             :     MSWordExportBase& m_rExport;
    1508             :     SwFmt** pFmtA;
    1509             :     sal_uInt16 nUsedSlots;
    1510             : 
    1511             :     /// Create the style table, called from the constructor.
    1512             :     void BuildStylesTable();
    1513             : 
    1514             :     /// Get slot number during building the style table.
    1515             :     sal_uInt16 BuildGetSlot( const SwFmt& rFmt );
    1516             : 
    1517             :     /// Return information about one style.
    1518             :     void GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase, sal_uInt16& nNext );
    1519             : 
    1520             :     /// Outputs attributes of one style.
    1521             :     void WriteProperties( const SwFmt* pFmt, bool bPap, sal_uInt16 nPos, bool bInsDefCharSiz );
    1522             : 
    1523             :     sal_uInt16 GetWWId( const SwFmt& rFmt ) const;
    1524             : 
    1525             :     void SetStyleDefaults( const SwFmt& rFmt, bool bPap );
    1526             : 
    1527             :     /// Outputs one style - called (in a loop) from OutputStylesTable().
    1528             :     void OutputStyle( SwFmt* pFmt, sal_uInt16 nPos );
    1529             : 
    1530             :     // No copying
    1531             :     MSWordStyles( const MSWordStyles& );
    1532             :     MSWordStyles& operator=( const MSWordStyles& );
    1533             : 
    1534             : public:
    1535             :     MSWordStyles( MSWordExportBase& rExport );
    1536             :     ~MSWordStyles();
    1537             : 
    1538             :     /// Output the styles table.
    1539             :     void OutputStylesTable();
    1540             : 
    1541             :     /// Get id of the style (rFmt).
    1542             :     sal_uInt16 GetSlot( const SwFmt& rFmt ) const;
    1543             : 
    1544          50 :     const SwFmt* GetSwFmt() const { return (*pFmtA); }
    1545             : };
    1546             : 
    1547             : sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt);
    1548             : // A bit of a bag on the side for now
    1549             : String FieldString(ww::eField eIndex);
    1550             : String BookmarkToWord(const String &rBookmark);
    1551             : 
    1552             : class WW8SHDLong
    1553             : {
    1554             :     sal_uInt32 m_cvFore;
    1555             :     sal_uInt32 m_cvBack;
    1556             :     sal_uInt16 m_ipat;
    1557             : 
    1558             : public:
    1559         236 :     WW8SHDLong() : m_cvFore(0), m_cvBack(0), m_ipat(0) {}
    1560         236 :     virtual ~WW8SHDLong() {}
    1561             : 
    1562             :     void Write(WW8Export & rExport);
    1563         236 :     void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; }
    1564         236 :     void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; }
    1565             :     void setIPat(sal_uInt16 ipat) { m_ipat = ipat; }
    1566             : };
    1567             : 
    1568             : #endif  //  _WRTWW8_HXX
    1569             : 
    1570             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10