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