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