merge the formfield patch from ooo-build
[ooovba.git] / sw / source / filter / ww8 / wrtww8.hxx
blob1f3e9f247cd02b0db57f213195e0a3428f62a72f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: wrtww8.hxx,v $
10 * $Revision: 1.76.172.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */
32 #ifndef _WRTWW8_HXX
33 #define _WRTWW8_HXX
35 #include <tools/solar.h> // UINTXX
36 #include <tools/gen.hxx>
37 #ifndef _SVSTDARR_HXX
38 #define _SVSTDARR_ULONGS
39 #include <svtools/svstdarr.hxx>
40 #endif
42 #include <map>
43 #include <vector>
45 #include <shellio.hxx>
46 #include <wrt_fn.hxx>
47 #include <svx/msocximex.hxx>
49 #include "ww8struc.hxx"
50 #include "ww8scan.hxx"
51 #include "fields.hxx"
52 #include "types.hxx"
53 #include "writerhelper.hxx"
54 #include "../inc/msfilter.hxx"
55 #include <expfld.hxx>
57 // einige Forward Deklarationen
58 class SwAttrIter;
59 class AttributeOutputBase;
60 class DocxAttributeOutput;
61 class BitmapPalette;
62 class SwEscherEx;
63 class DateTime;
64 class Font;
65 class MSWordExportBase;
66 class SdrObject;
67 class SfxItemSet;
68 class SvStream;
69 class SvxBorderLine;
70 class SvxFontItem;
71 class SvxBoxItem;
72 class SwAttrSet;
73 class SwCharFmt;
74 class SwCntntNode;
75 class SwField;
76 class SwFmt;
77 class SwFmtCntnt;
78 class SwFmtFtn;
79 class SwFrmFmt;
80 class SwGrfNode;
81 class SwModify;
82 class SwNumFmt;
83 class SwNumRule;
84 class SwNumRuleTbl;
85 class SwPageDesc;
86 class SwFmtPageDesc;
87 class SwOLENode;
88 class SwPostItField;
89 class SwRedlineData;
90 class SwSection;
91 class SwSectionFmt;
92 class SwSectionNode;
93 class SwTableNode;
94 class SwTOXType;
95 class SwTxtAttr;
96 class SwTxtFmtColl;
97 class SwTxtNode;
98 class SwWW8WrGrf;
99 class SwWW8Writer;
100 class MSWordStyles;
101 class WW8AttributeOutput;
102 class WW8Bytes;
103 class WW8Export;
104 class MSWordAttrIter;
105 class WW8_WrFkp;
106 class WW8_WrPlc0;
107 class WW8_WrPlc1;
108 class WW8_WrPlcFld;
109 class WW8_WrMagicTable;
110 class WW8_WrPlcFtnEdn;
111 class WW8_WrPlcPn;
112 class WW8_WrPlcPostIt;
113 class MSWordSections;
114 class WW8_WrPlcTxtBoxes;
115 class WW8_WrPct; // Verwaltung
116 class WW8_WrPcPtrs;
117 class WW8_WrtBookmarks;
118 class WW8_WrtRedlineAuthor;
119 class SvxMSExportOLEObjects;
120 class SwMSConvertControls;
121 class WW8OleMaps;
122 class SvStorageRef;
123 struct WW8_PdAttrDesc;
124 class SvxBrushItem;
126 #include "WW8TableInfo.hxx"
128 #define GRF_MAGIC_1 0x12 // 3 magic Bytes fuer PicLocFc-Attribute
129 #define GRF_MAGIC_2 0x34
130 #define GRF_MAGIC_3 0x56
131 #define GRF_MAGIC_321 0x563412L
133 #define OLE_PREVIEW_AS_EMF //If we want to export ole2 previews as emf in ww8+
135 typedef BYTE FieldFlags;
136 namespace nsFieldFlags // for InsertField- Method
138 const FieldFlags WRITEFIELD_START = 0x01;
139 const FieldFlags WRITEFIELD_CMD_START = 0x02;
140 const FieldFlags WRITEFIELD_CMD_END = 0x04;
141 const FieldFlags WRITEFIELD_END = 0x10;
142 const FieldFlags WRITEFIELD_CLOSE = 0x20;
143 const FieldFlags WRITEFIELD_ALL = 0xFF;
146 enum TxtTypes //enums for TextTypes
148 TXT_MAINTEXT = 0, /*TXT_FTNEDN = 1,*/ TXT_HDFT = 2, TXT_FTN = 3,
149 TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7
152 SV_DECL_VARARR( WW8Bytes, BYTE, 128, 128 )
154 struct WW8_SepInfo
156 const SwPageDesc* pPageDesc;
157 const SwSectionFmt* pSectionFmt;
158 const SwNode* pPDNd;
159 const SwTxtNode* pNumNd;
160 ULONG nLnNumRestartNo;
161 USHORT nPgRestartNo;
163 WW8_SepInfo()
164 : pPageDesc(0), pSectionFmt(0), pPDNd(0), pNumNd(0), nLnNumRestartNo(0), nPgRestartNo(0)
168 WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFmt* pFmt,
169 ULONG nLnRestart, USHORT nPgRestart = 0, const SwNode* pNd = NULL )
170 : pPageDesc( pPD ), pSectionFmt( pFmt ), pPDNd( pNd ), pNumNd( 0 ),
171 nLnNumRestartNo( nLnRestart ), nPgRestartNo( nPgRestart )
174 bool IsProtected() const;
177 SV_DECL_VARARR( WW8_WrSepInfoPtrs, WW8_SepInfo, 4, 4 )
179 /// Class to collect and output the sections/headers/footers.
180 // Plc fuer PageDescs -> Sepx ( Section Extensions )
181 class MSWordSections
183 protected:
184 bool mbDocumentIsProtected;
185 WW8_WrSepInfoPtrs aSects; // PTRARR von SwPageDesc und SwSectionFmt
187 void CheckForFacinPg( WW8Export& rWrt ) const;
188 void WriteOlst( WW8Export& rWrt, const WW8_SepInfo& rSectionInfo );
189 void NeedsDocumentProtected(const WW8_SepInfo &rInfo);
191 //No copy, no assign
192 MSWordSections( const MSWordSections& );
193 MSWordSections& operator=( const MSWordSections& );
194 public:
195 MSWordSections( MSWordExportBase& rExport );
196 ~MSWordSections();
198 void AppendSep( const SwPageDesc* pPd,
199 const SwSectionFmt* pSectionFmt = 0,
200 ULONG nLnNumRestartNo = 0 );
201 void AppendSep( const SwFmtPageDesc& rPd,
202 const SwNode& rNd,
203 const SwSectionFmt* pSectionFmt,
204 ULONG nLnNumRestartNo );
205 void SetNum( const SwTxtNode* pNumNd );
207 /// Number of columns based on the most recent WW8_SepInfo.
208 sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
210 /// Number of columns of the provided WW8_SepInfo.
211 sal_uInt16 NumberOfColumns( const SwDoc &rDoc, const WW8_SepInfo& rInfo ) const;
213 bool DocumentIsProtected() const { return mbDocumentIsProtected; }
215 /// The most recent WW8_SepInfo.
216 const WW8_SepInfo* CurrentSectionInfo();
218 static void SetHeaderFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
219 BYTE nFlag );
220 static void SetFooterFlag( BYTE& rHeadFootFlags, const SwFmt& rFmt,
221 BYTE nFlag );
223 /// Should we output borders?
224 static int HasBorderItem( const SwFmt& rFmt );
227 class WW8_WrPlcSepx : public MSWordSections
229 SvULongs aCps; // PTRARR von CPs
230 WW8_PdAttrDesc* pAttrs;
231 WW8_WrPlc0* pTxtPos; // Pos der einzelnen Header / Footer
233 // No copy, no assign
234 WW8_WrPlcSepx( const WW8_WrPlcSepx& );
235 WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& );
237 public:
238 WW8_WrPlcSepx( MSWordExportBase& rExport );
239 ~WW8_WrPlcSepx();
241 void AppendSep( WW8_CP nStartCp,
242 const SwPageDesc* pPd,
243 const SwSectionFmt* pSectionFmt = 0,
244 ULONG nLnNumRestartNo = 0 );
245 void AppendSep( WW8_CP nStartCp, const SwFmtPageDesc& rPd,
246 const SwNode& rNd,
247 const SwSectionFmt* pSectionFmt,
248 ULONG nLnNumRestartNo );
249 void Finish( WW8_CP nEndCp ) { aCps.Insert( nEndCp, aCps.Count() ); }
251 bool WriteKFTxt( WW8Export& rWrt );
252 void WriteSepx( SvStream& rStrm ) const;
253 void WritePlcSed( WW8Export& rWrt ) const;
254 void WritePlcHdd( WW8Export& rWrt ) const;
256 private:
257 void WriteFtnEndTxt( WW8Export& rWrt, ULONG nCpStt );
258 public:
259 void OutHeaderFooter(WW8Export& rWrt, bool bHeader,
260 const SwFmt& rFmt, ULONG& rCpPos, BYTE nHFFlags, BYTE nFlag, BYTE nBreakCode);
263 //--------------------------------------------------------------------------
264 // class WW8_WrPct zum Aufbau der Piece-Table
265 //--------------------------------------------------------------------------
266 class WW8_WrPct
268 WW8_WrPcPtrs* pPcts;
269 WW8_FC nOldFc;
270 bool bIsUni;
271 public:
272 WW8_WrPct(WW8_FC nStartFc, bool bSaveUniCode);
273 ~WW8_WrPct();
274 void AppendPc(WW8_FC nStartFc, bool bIsUnicode);
275 void WritePc( WW8Export& rWrt );
276 void SetParaBreak();
277 bool IsUnicode() const { return bIsUni; }
278 WW8_CP Fc2Cp( ULONG nFc ) const;
281 /// Collects and outputs fonts.
282 class wwFont
284 //In some future land the stream could be converted to a nice stream interface
285 //and we could have harmony
286 private:
287 BYTE maWW8_FFN[6];
288 String msFamilyNm;
289 String msAltNm;
290 bool mbAlt;
291 bool mbWrtWW8;
292 FontPitch mePitch;
293 FontFamily meFamily;
294 rtl_TextEncoding meChrSet;
295 public:
296 wwFont( const String &rFamilyName, FontPitch ePitch, FontFamily eFamily,
297 rtl_TextEncoding eChrSet, bool bWrtWW8 );
298 bool Write( SvStream *pTableStram ) const;
299 #ifdef DOCX
300 void WriteDocx( const DocxAttributeOutput* rAttrOutput ) const;
301 #endif
302 rtl::OUString GetFamilyName() const { return rtl::OUString( msFamilyNm ); }
303 friend bool operator < (const wwFont &r1, const wwFont &r2);
306 class wwFontHelper
308 private:
309 /// Keep track of fonts that need to be exported.
310 ::std::map<wwFont, USHORT> maFonts;
311 bool mbWrtWW8;
313 /// Convert from fast insertion map to linear vector in the order that we want to write.
314 ::std::vector< const wwFont* > AsVector() const;
316 public:
317 wwFontHelper() : mbWrtWW8(false) {}
318 /// rDoc used only to get the initial standard font(s) in use.
319 void InitFontTable(bool bWrtWW8, const SwDoc& rDoc);
320 USHORT GetId(const Font& rFont);
321 USHORT GetId(const SvxFontItem& rFont);
322 USHORT GetId(const wwFont& rFont);
323 void WriteFontTable( SvStream *pTableStream, WW8Fib& pFib );
324 #ifdef DOCX
325 void WriteFontTable( const DocxAttributeOutput& rAttrOutput );
326 #endif
329 class DrawObj
331 public:
332 WW8_CP mnCp; // CP-Pos der Verweise
333 UINT32 mnShapeId; // ShapeId for the SwFrmFmts
334 sw::Frame maCntnt; // the frame itself
335 Point maParentPos; // Points
336 INT32 mnThick; // Border Thicknesses
337 short mnDirection; // If BiDi or not
338 unsigned int mnHdFtIndex; // 0 for main text, +1 for each subsequent
339 // msword hd/ft
341 DrawObj(const sw::Frame &rCntnt, WW8_CP nCp, Point aParentPos, short nDir,
342 unsigned int nHdFtIndex)
343 : mnCp(nCp), mnShapeId(0), maCntnt(rCntnt), maParentPos(aParentPos),
344 mnThick(0), mnDirection(nDir), mnHdFtIndex(nHdFtIndex) {}
345 void SetShapeDetails(UINT32 nId, INT32 nThick);
346 DrawObj& operator=(const DrawObj &rOther);
349 typedef std::vector<DrawObj> DrawObjVector;
350 typedef DrawObjVector::iterator DrawObjIter;
351 typedef DrawObjVector::const_iterator cDrawObjIter;
353 typedef std::vector<DrawObj *> DrawObjPointerVector;
354 typedef DrawObjPointerVector::iterator DrawObjPointerIter;
356 class PlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes
358 private:
359 DrawObjVector maDrawObjs; // vector of drawobjs
360 protected:
361 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
362 sal_uInt32 nLen) const = 0;
363 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const = 0;
364 public:
365 PlcDrawObj() {}
366 void WritePlc( WW8Export& rWrt ) const;
367 bool Append( WW8Export&, WW8_CP nCp, const sw::Frame& rFmt,
368 const Point& rNdTopLeft );
369 int size() { return maDrawObjs.size(); };
370 DrawObjVector &GetObjArr() { return maDrawObjs; }
371 virtual ~PlcDrawObj();
372 private:
373 //No copying
374 PlcDrawObj(const PlcDrawObj&);
375 PlcDrawObj& operator=(const PlcDrawObj&);
378 class MainTxtPlcDrawObj : public PlcDrawObj
380 public:
381 MainTxtPlcDrawObj() {}
382 private:
383 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
384 sal_uInt32 nLen) const;
385 virtual WW8_CP GetCpOffset(const WW8Fib &) const;
386 private:
387 //No copying
388 MainTxtPlcDrawObj(const MainTxtPlcDrawObj&);
389 MainTxtPlcDrawObj& operator=(const MainTxtPlcDrawObj&);
392 class HdFtPlcDrawObj : public PlcDrawObj
394 public:
395 HdFtPlcDrawObj() {}
396 private:
397 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
398 sal_uInt32 nLen) const;
399 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const;
400 private:
401 //No copying
402 HdFtPlcDrawObj(const HdFtPlcDrawObj&);
403 HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&);
406 typedef ::std::pair<String, ULONG> aPair;
407 typedef std::vector<aPair> SwImplBookmarks;
408 typedef std::vector<aPair>::iterator SwImplBookmarksIter;
410 class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor
412 public:
413 virtual void Write(Writer &rWrt);
416 /** Structure that is used to save some of the WW8Export/DocxExport data.
418 It is used to be able to recurse inside of the WW8Export/DocxExport (eg.
419 for the needs of the tables) - you need to tall WriteText() from there with
420 new values of PaM etc.
422 It must contain all the stuff that might be saved either in WW8Export or in
423 DocxExport, because it makes no sense to do it abstract, and specialize it
424 for each of the cases. If you implement other *Export, just add the needed
425 members here, and store them in the appropriate SaveData() method.
427 struct MSWordSaveData
429 Point* pOldFlyOffset;
430 RndStdIds eOldAnchorType;
431 WW8Bytes* pOOld; ///< WW8Export only
432 WW8Bytes* mpTableAtOld; ///< WW8Export only: Additional buffer for the output of the tables
433 sal_uInt16 mnTableStdAtLenOld; ///< WW8Export only: Standard length of mpTableAt
434 SwPaM* pOldPam, *pOldEnd;
435 const sw::Frame* pOldFlyFmt;
436 const SwPageDesc* pOldPageDesc;
438 BYTE bOldWriteAll : 1; ///< WW8Export only
439 BYTE bOldOutTable : 1;
440 BYTE bOldIsInTable: 1;
441 BYTE bOldFlyFrmAttrs : 1;
442 BYTE bOldStartTOX : 1;
443 BYTE bOldInWriteTOX : 1;
444 // bOutPageDesc muss nicht gesichert werden, da es nur nicht waehrend der
445 // Ausgabe von Spezial-Texten veraendert wird.
448 /// Base class for WW8Export and DocxExport
449 class MSWordExportBase
451 public:
452 wwFontHelper maFontHelper;
453 std::vector<ULONG> maChapterFieldLocs;
454 typedef std::vector<ULONG>::const_iterator mycCFIter;
455 String aMainStg;
456 SvPtrarr aTOXArr;
457 const SfxItemSet* pISet; // fuer Doppel-Attribute
458 WW8_WrPct* pPiece; // Pointer auf Piece-Table
459 SwNumRuleTbl* pUsedNumTbl; // alle used NumRules
460 const SwTxtNode *mpTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft
461 std::map< USHORT, USHORT > aRuleDuplicates; //map to Duplicated numrules
462 std::stack< xub_StrLen > m_aCurrentCharPropStarts; ///< To remember the position in a run.
463 WW8_WrtBookmarks* pBkmks;
464 WW8_WrtRedlineAuthor* pRedlAuthors;
465 BitmapPalette* pBmpPal;
466 void* pKeyMap;
467 SvxMSExportOLEObjects* pOLEExp;
468 SwMSConvertControls* pOCXExp;
469 WW8OleMaps* pOleMap;
470 ww8::WW8TableInfo::Pointer_t mpTableInfo;
472 USHORT nCharFmtStart;
473 USHORT nFmtCollStart;
474 USHORT nStyleBeforeFly; ///< Style-Nummer des Nodes,
475 ///< in/an dem ein Fly verankert ist
476 USHORT nLastFmtId; ///< Style of last TxtNode in normal range
477 USHORT nUniqueList; ///< current number for creating unique list names
478 unsigned int mnHdFtIndex;
480 USHORT mnRedlineMode; ///< Remember the original redline mode
482 public:
483 /* implicit bookmark vector containing pairs of node indexes and bookmark names */
484 SwImplBookmarks maImplicitBookmarks;
485 sw::Frames maFrames; // The floating frames in this document
486 const SwPageDesc *pAktPageDesc;
487 WW8_WrPlcPn* pPapPlc;
488 WW8_WrPlcPn* pChpPlc;
489 MSWordAttrIter* pChpIter;
490 MSWordStyles* pStyles;
491 WW8_WrPlcPostIt* pAtn;
492 WW8_WrPlcTxtBoxes *pTxtBxs, *pHFTxtBxs;
494 const sw::Frame *mpParentFrame; //If set we are exporting content inside
495 //a frame, e.g. a graphic node
497 Point* pFlyOffset; // zur Justierung eines im Writer als
498 RndStdIds eNewAnchorType; // Zeichen gebundenen Flys, der im WW
499 // Absatzgebunden wird.
501 WW8_WrPlcFld* pFldMain; // Felder im Haupttext
502 WW8_WrPlcFld* pFldHdFt; // Felder in Header/Footer
503 WW8_WrPlcFld* pFldFtn; // Felder in FootNotes
504 WW8_WrPlcFld* pFldEdn; // Felder in EndNotes
505 WW8_WrPlcFld* pFldAtn; // Felder in Annotations
506 WW8_WrPlcFld* pFldTxtBxs; // fields in textboxes
507 WW8_WrPlcFld* pFldHFTxtBxs; // fields in header/footer textboxes
508 WW8_WrMagicTable *pMagicTable; // keeps track of table cell positions, and
509 // marks those that contain graphics,
510 // which is required to make word display
511 // graphics inside tables
512 SwWW8WrGrf* pGrf;
513 const SwAttrSet* pStyAttr; // StyleAttr fuer Tabulatoren
514 const SwModify* pOutFmtNode; // write Format or Node
515 const SwFmt *pCurrentStyle; // iff bStyDef=true, then this store the current style
517 MainTxtPlcDrawObj *pSdrObjs; // Draw-/Fly-Objects
518 HdFtPlcDrawObj *pHFSdrObjs; // Draw-/Fly-Objects in header or footer
520 SwEscherEx* pEscher; // escher export class
521 // --> OD 2007-04-19 #i43447# - removed
522 // SwTwips nFlyWidth, nFlyHeight; // Fuer Anpassung Graphic
523 // <--
525 BYTE nTxtTyp;
527 BYTE bStyDef : 1; // wird Style geschrieben ?
528 BYTE bBreakBefore : 1; // Breaks werden 2mal ausgegeben
529 BYTE bOutKF : 1; // Kopf/Fusstexte werden ausgegeben
530 BYTE bOutFlyFrmAttrs : 1; // Rahmen-Attr von Flys werden ausgegeben
531 BYTE bOutPageDescs : 1; ///< PageDescs (section properties) are being written
532 BYTE bOutFirstPage : 1; // write Attrset of FirstPageDesc
533 BYTE bOutTable : 1; // Tabelle wird ausgegeben
534 // ( wird zB bei Flys in Tabelle zurueckgesetzt )
535 BYTE bIsInTable : 1; // wird sind innerhalb der Ausgabe einer Tabelle
536 // ( wird erst nach der Tabelle zurueckgesetzt )
537 BYTE bOutGrf : 1; // Grafik wird ausgegeben
538 BYTE bInWriteEscher : 1; // in write textboxes
539 BYTE bStartTOX : 1; // true: a TOX is startet
540 BYTE bInWriteTOX : 1; // true: all content are in a TOX
541 BYTE bFtnAtTxtEnd : 1; // true: all FTN at Textend
542 BYTE bEndAtTxtEnd : 1; // true: all END at Textend
543 BYTE bHasHdr : 1;
544 BYTE bHasFtr : 1;
546 SwDoc *pDoc;
547 SwPaM *pCurPam, *pOrigPam;
549 /// Stack to remember the nesting (see MSWordSaveData for more)
550 ::std::stack< MSWordSaveData > maSaveData;
552 public:
553 /// The main function to export the document.
554 void ExportDocument( bool bWriteAll );
556 /// Iterate through the nodes and call the appropriate OutputNode() on them.
557 void WriteText();
559 /// Set the pCurPam appropriately and call WriteText().
561 /// Used to export paragraphs in footnotes/endnotes/etc.
562 void WriteSpecialText( ULONG nStart, ULONG nEnd, BYTE nTTyp );
564 /// Export the pool items to attributes (through an attribute output class).
565 void ExportPoolItemsToCHP( sw::PoolItems &rItems, USHORT nScript );
567 /// Return the numeric id of the numbering rule
568 USHORT GetId( const SwNumRule& rNumRule );
570 /// Return the numeric id of the style.
571 USHORT GetId( const SwTxtFmtColl& rColl ) const;
573 /// Return the numeric id of the style.
574 USHORT GetId( const SwCharFmt& rFmt ) const;
576 USHORT GetId( const SwTOXType& rTOXType );
578 const SfxPoolItem& GetItem( USHORT nWhich ) const;
580 /// Find the reference.
581 bool HasRefToObject( USHORT nTyp, const String* pName, USHORT nSeqNo );
583 /// Find the bookmark name.
584 String GetBookmarkName( USHORT nTyp, const String* pName, USHORT nSeqNo );
586 /// Add a bookmark converted to a Word name.
587 void AppendWordBookmark( const String& rName );
589 /// Use OutputItem() on an item set according to the parameters.
590 void OutputItemSet( const SfxItemSet& rSet, bool bPapFmt, bool bChpFmt, USHORT nScript );
592 short GetDefaultFrameDirection( ) const;
594 /// Right to left?
595 short TrueFrameDirection( const SwFrmFmt& rFlyFmt ) const;
597 /// Right to left?
598 short GetCurrentPageDirection() const;
600 /// In case of numbering restart.
602 /// List is set to restart at a particular value so for export make a
603 /// completely new list based on this one and export that instead,
604 /// which duplicates words behaviour in this respect.
605 USHORT DuplicateNumRule( const SwNumRule *pRule, BYTE nLevel, USHORT nVal );
607 /// Access to the attribute output class.
608 virtual AttributeOutputBase& AttrOutput() const = 0;
610 /// Access to the sections/headers/footres.
611 virtual MSWordSections& Sections() const = 0;
613 /// Hack, unfortunately necessary at some places for now.
614 /// FIXME remove it when possible.
615 virtual bool HackIsWW8OrHigher() const = 0;
617 /// Guess the script (asian/western).
619 /// Sadly word does not have two different sizes for asian font size and
620 /// western font size, it has two different fonts, but not sizes, so we
621 /// have to use our guess as to the script used and disable the export of
622 /// one type. The same occurs for font weight and posture (bold and
623 /// italic).
625 /// In addition WW7- has only one character language identifier while WW8+
626 /// has two
627 virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich ) = 0;
629 virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen ) = 0;
631 virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ) = 0;
633 // FIXME probably a hack...
634 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0;
636 // FIXME definitely a hack, must not be here - it can't do anything
637 // sensible for docx
638 virtual void WriteChar( sal_Unicode c ) = 0;
640 /// Output attributes.
641 void OutputFormat( const SwFmt& rFmt, bool bPapFmt, bool bChpFmt, bool bFlyFmt = false );
643 /// Getter for pISet.
644 const SfxItemSet* GetCurItemSet() const { return pISet; }
646 /// Setter for pISet.
647 void SetCurItemSet( const SfxItemSet* pS ) { pISet = pS; }
649 /// Remember some of the memebers so that we can recurse in WriteText().
650 virtual void SaveData( ULONG nStt, ULONG nEnd );
652 /// Restore what was saved in SaveData().
653 virtual void RestoreData();
655 /// The return value indicates, if a follow page desc is written.
656 bool OutputFollowPageDesc( const SfxItemSet* pSet,
657 const SwTxtNode* pNd );
659 /// Write header/footer text.
660 void WriteHeaderFooterText( const SwFmt& rFmt, bool bHeader);
662 /// Format of the section.
663 const SwSectionFmt* GetSectionFormat( const SwNode& rNd ) const;
665 /// Line number of the section start.
666 ULONG GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd ) const;
668 /// Start new section.
669 void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd );
671 /// Write section properties.
673 /// pA is ignored for docx.
674 void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = NULL );
676 /// Output the numbering table.
677 virtual void WriteNumbering() = 0;
679 /// Write static data of SwNumRule - LSTF
680 void NumberingDefinitions();
682 /// Write all Levels for all SwNumRules - LVLF
683 void AbstractNumberingDefinitions();
685 // Convert the bullet according to the font.
686 void SubstituteBullet( String& rNumStr, rtl_TextEncoding& rChrSet,
687 String& rFontName ) const;
689 /// No-op for the newer WW versions.
690 virtual void OutputOlst( const SwNumRule& /*rRule*/ ) {}
692 /// Setup the pA's info.
693 virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {}
695 /// Top node of host page when in header/footer.
696 void SetHdFtPageRoot( const SwTxtNode *pNd ) { mpTopNodeOfHdFtPage = pNd; }
698 /// Top node of host page when in header/footer.
699 const SwTxtNode *GetHdFtPageRoot() const { return mpTopNodeOfHdFtPage; }
701 /// Output the actual headers and footers.
702 virtual void WriteHeadersFooters( BYTE nHeadFootFlags,
703 const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
704 BYTE nBreakCode) = 0;
706 /// Write the field
707 virtual void OutputField( const SwField* pFld, ww::eField eFldType,
708 const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL ) = 0;
710 /// Write the data of the form field
711 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
712 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
714 virtual void DoComboBox(const rtl::OUString &rName,
715 const rtl::OUString &rHelp,
716 const rtl::OUString &ToolTip,
717 const rtl::OUString &rSelected,
718 com::sun::star::uno::Sequence<rtl::OUString> &rListItems) = 0;
720 virtual void DoFormText(const SwInputField * pFld) = 0;
722 static bool NoPageBreakSection( const SfxItemSet *pSet );
724 // Compute the number format for WW dates
725 bool GetNumberFmt(const SwField& rFld, String& rStr);
727 virtual ULONG ReplaceCr( BYTE nChar ) = 0;
729 const SfxPoolItem* HasItem( USHORT nWhich ) const;
732 protected:
733 /// Format-dependant part of the actual export.
734 virtual void ExportDocument_Impl() = 0;
736 /// Get the next position in the text node to output
737 virtual xub_StrLen GetNextPos( SwAttrIter* pAttrIter, const SwTxtNode& rNode, xub_StrLen nAktPos );
739 /// Update the information for GetNextPos().
740 virtual void UpdatePosition( SwAttrIter* pAttrIter, xub_StrLen nAktPos, xub_StrLen nEnd );
742 /// Output SwTxtNode
743 void OutputTextNode( const SwTxtNode& );
745 /// Output SwTableNode
746 void OutputTableNode( const SwTableNode& );
748 /// Setup the chapter fields (maChapterFieldLocs).
749 void GatherChapterFields();
751 void AddLinkTarget( const String& rURL );
752 void CollectOutlineBookmarks( const SwDoc &rDoc );
754 bool SetAktPageDescFromNode(const SwNode &rNd);
755 bool CntntContainsChapterField(const SwFmtCntnt &rCntnt) const;
756 bool FmtHdFtContainsChapterField(const SwFrmFmt &rFmt) const;
758 virtual void SectionBreaksAndFrames( const SwTxtNode& rNode ) = 0;
760 virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
761 const SwNode& rNd,
762 const SwFmtPageDesc* pNewPgDescFmt = 0,
763 const SwPageDesc* pNewPgDesc = 0 ) = 0;
765 /// Return value indicates if an inherited outline numbering is suppressed.
766 virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0;
768 protected:
769 /// Output SwEndNode
770 virtual void OutputEndNode( const SwEndNode& );
772 /// Output SwGrfNode
773 virtual void OutputGrfNode( const SwGrfNode& ) = 0;
775 /// Output SwOLENode
776 virtual void OutputOLENode( const SwOLENode& ) = 0;
778 /// Output SwSectionNode
779 virtual void OutputSectionNode( const SwSectionNode& );
781 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum ) = 0;
783 /// Call the right (virtual) function according to the type of the item.
785 /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode()
786 void OutputContentNode( const SwCntntNode& );
788 public:
789 MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam );
790 virtual ~MSWordExportBase();
792 // TODO move as much as possible here from WW8Export! ;-)
794 static void CorrectTabStopInSet( SfxItemSet& rSet, USHORT nAbsLeft );
796 private:
797 /// No copying.
798 MSWordExportBase( const MSWordExportBase& );
799 /// No copying.
800 MSWordExportBase& operator=( const MSWordExportBase& );
803 /// The writer class that gets called for the WW8 filter.
804 class SwWW8Writer: public StgWriter
806 // friends to get access to m_pExport
807 // FIXME avoid that, this is probably not what we want
808 // (if yes, remove the friends, and provide here a GetExport() method)
809 friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt);
811 bool m_bWrtWW8;
812 WW8Export *m_pExport;
813 SfxMedium *mpMedium;
815 public:
816 SwWW8Writer( const String& rFltName, const String& rBaseURL );
817 virtual ~SwWW8Writer();
819 virtual ULONG WriteStorage();
820 virtual ULONG WriteMedium( SfxMedium& );
822 // TODO most probably we want to be able to get these in
823 // MSExportFilterBase
824 using Writer::getIDocumentSettingAccess;
826 public:
827 #if 1
828 /// Prefer ww::bytes to WW8Bytes, migrate away from the other ones.
829 static void InsUInt16(ww::bytes &rO, sal_uInt16 n);
830 static void InsUInt32(ww::bytes &rO, sal_uInt32 n);
831 static void InsAsString16(ww::bytes &rO, const String& rStr);
832 static void InsAsString8(ww::bytes & O, const String& rStr,
833 rtl_TextEncoding eCodeSet);
834 #endif
836 static void InsUInt16( WW8Bytes& rO, UINT16 );
837 static void InsUInt32( WW8Bytes& rO, UINT32 );
838 static void InsAsString16( WW8Bytes& rO, const String& );
839 static void InsAsString8( WW8Bytes& rO, const String& rStr,
840 rtl_TextEncoding eCodeSet );
842 static ULONG FillUntil( SvStream& rStrm, ULONG nEndPos = 0 );
843 static void FillCount( SvStream& rStrm, ULONG nCount );
845 static void WriteShort( SvStream& rStrm, INT16 nVal ) { rStrm << nVal; }
846 static void WriteShort( SvStream& rStrm, ULONG nPos, INT16 nVal );
848 static void WriteLong( SvStream& rStrm, INT32 nVal ) { rStrm << nVal; }
849 static void WriteLong( SvStream& rStrm, ULONG nPos, INT32 nVal );
851 static void WriteString16(SvStream& rStrm, const String& rStr,
852 bool bAddZero);
853 static void WriteString8(SvStream& rStrm, const String& rStr,
854 bool bAddZero, rtl_TextEncoding eCodeSet);
856 static void WriteString_xstz(SvStream& rStrm, const String& rStr, bool bAddZero);
858 String GetPassword();
860 using StgWriter::Write;
861 virtual ULONG Write( SwPaM&, SfxMedium&, const String* = 0 );
863 private:
864 /// No copying.
865 SwWW8Writer(const SwWW8Writer&);
866 /// No copying.
867 SwWW8Writer& operator=(const SwWW8Writer&);
870 /// Exporter of the binary Word file formats.
871 class WW8Export : public MSWordExportBase
873 public:
874 WW8Bytes* pO; ///< Buffer
875 WW8Bytes* mpTableAt; ///< Additional buffer for the output of the tables
876 sal_uInt16 mnTableStdAtLen; ///< Standard length of mpTableAt
878 SvStream *pTableStrm, *pDataStrm; ///< Streams for WW97 Export
880 WW8Fib* pFib; ///< File Information Block
881 WW8Dop* pDop; ///< DOcument Properties
882 WW8_WrPlcFtnEdn *pFtn; ///< Footnotes - structure to remember them, and output
883 WW8_WrPlcFtnEdn *pEdn; ///< Endnotes - structure to remember them, and output
884 WW8_WrPlcSepx* pSepx; ///< Sections/headers/footers
886 BYTE bWrtWW8 : 1; ///< Write WW95 (false) or WW97 (true) file format
888 protected:
889 SwWW8Writer *m_pWriter; ///< Pointer to the writer
890 WW8AttributeOutput *m_pAttrOutput; ///< Converting attributes to stream data
892 public:
893 /// Access to the attribute output class.
894 virtual AttributeOutputBase& AttrOutput() const;
896 /// Access to the sections/headers/footres.
897 virtual MSWordSections& Sections() const;
899 /// False for WW6, true for WW8.
900 virtual bool HackIsWW8OrHigher() const { return bWrtWW8; }
902 private:
903 /// Format-dependant part of the actual export.
904 virtual void ExportDocument_Impl();
906 void PrepareStorage();
907 void WriteFkpPlcUsw();
908 void WriteMainText();
909 void StoreDoc1();
910 void Out_WwNumLvl( BYTE nWwLevel );
911 void BuildAnlvBulletBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen,
912 const SwNumFmt& rFmt );
913 static void BuildAnlvBase( WW8_ANLV& rAnlv, BYTE*& rpCh, USHORT& rCharLen,
914 const SwNumRule& rRul, const SwNumFmt& rFmt, BYTE nSwLevel );
916 void Out_BorderLine(WW8Bytes& rO, const SvxBorderLine* pLine,
917 USHORT nDist, sal_uInt16 nSprmNo, bool bShadow);
919 /// Output the numbering table.
920 virtual void WriteNumbering();
922 void OutOverrideListTab();
923 void OutListNamesTab();
925 void RestoreMacroCmds();
927 void InitFontTable();
929 void DoComboBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
930 void DoCheckBox(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> xPropSet);
932 public:
933 virtual void OutputOlst( const SwNumRule& rRule );
935 /// Setup the pA's info.
936 virtual void SetupSectionPositions( WW8_PdAttrDesc* pA );
938 void Out_SwNumLvl( BYTE nSwLevel );
939 void Out_NumRuleAnld( const SwNumRule& rRul, const SwNumFmt& rFmt,
940 BYTE nSwLevel );
942 bool MiserableFormFieldExportHack(const SwFrmFmt& rFrmFmt);
944 SvxMSExportOLEObjects& GetOLEExp() { return *pOLEExp; }
945 SwMSConvertControls& GetOCXExp() { return *pOCXExp; }
946 WW8OleMaps& GetOLEMap() { return *pOleMap; }
947 void ExportDopTypography(WW8DopTypography &rTypo);
949 using MSWordExportBase::GetId;
950 USHORT GetId( const SvxFontItem& rFont)
952 return maFontHelper.GetId(rFont);
955 USHORT AddRedlineAuthor( USHORT nId );
957 void WriteFtnBegin( const SwFmtFtn& rFtn, WW8Bytes* pO = 0 );
958 void WritePostItBegin( WW8Bytes* pO = 0 );
959 const SvxBrushItem* GetCurrentPageBgBrush() const;
960 SvxBrushItem TrueFrameBgBrush(const SwFrmFmt &rFlyFmt) const;
962 /// Output all textframes anchored as character for the winword 7- format.
963 void OutWW6FlyFrmsInCntnt( const SwTxtNode& rNd );
965 void AppendFlyInFlys(const sw::Frame& rFrmFmt, const Point& rNdTopLeft);
966 void WriteOutliner(const OutlinerParaObject& rOutliner, BYTE nTyp);
967 void WriteSdrTextObj(const SdrObject& rObj, BYTE nTyp);
969 UINT32 GetSdrOrdNum( const SwFrmFmt& rFmt ) const;
970 void CreateEscher();
971 void WriteEscher();
973 bool Out_SwNum(const SwTxtNode* pNd);
975 /// Write the field
976 virtual void OutputField( const SwField* pFld, ww::eField eFldType,
977 const String& rFldCmd, BYTE nMode = nsFieldFlags::WRITEFIELD_ALL );
979 void StartCommentOutput( const String& rName );
980 void EndCommentOutput( const String& rName );
981 void OutGrf(const sw::Frame &rFrame);
982 bool TestOleNeedsGraphic(const SwAttrSet& rSet, SvStorageRef xOleStg,
983 SvStorageRef xObjStg, String &rStorageName, SwOLENode *pOLENd);
985 virtual void AppendBookmarks( const SwTxtNode& rNd, xub_StrLen nAktPos, xub_StrLen nLen );
986 virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false );
987 void MoveFieldMarks(ULONG nFrom, ULONG nTo);
989 void WriteAsStringTable(const ::std::vector<String>&, INT32& rfcSttbf,
990 INT32& rlcbSttbf, USHORT nExtraLen = 0);
992 virtual ULONG ReplaceCr( BYTE nChar );
994 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() );
995 void WriteChar( sal_Unicode c );
996 #if 0
997 USHORT StartTableFromFrmFmt(WW8Bytes &rAt, const SwFrmFmt *pFmt,
998 SwTwips &rPageSize);
999 #endif
1001 void OutSwString(const String&, xub_StrLen nStt, xub_StrLen nLen,
1002 bool bUnicode, rtl_TextEncoding eChrSet);
1004 WW8_CP Fc2Cp( ULONG nFc ) const { return pPiece->Fc2Cp( nFc ); }
1006 // einige z.T. static halb-interne Funktions-Deklarationen
1008 void OutSprmBytes( BYTE* pBytes, USHORT nSiz )
1009 { pO->Insert( pBytes, nSiz, pO->Count() ); }
1011 inline bool IsUnicode() const { return pPiece->IsUnicode(); }
1013 virtual void SectionBreaksAndFrames( const SwTxtNode& rNode );
1015 /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc().
1016 // OD 2007-05-29 #i76300#
1017 virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
1018 const SwNode& rNd,
1019 const SwFmtPageDesc* pNewPgDescFmt = 0,
1020 const SwPageDesc* pNewPgDesc = 0 );
1022 void Out_SwFmtBox(const SvxBoxItem& rBox, bool bShadow);
1023 void Out_SwFmtTableBox( WW8Bytes& rO, const SvxBoxItem& rBox );
1024 BYTE TransCol( const Color& rCol );
1025 bool TransBrush(const Color& rCol, WW8_SHD& rShd);
1026 WW8_BRC TranslateBorderLine(const SvxBorderLine& pLine,
1027 USHORT nDist, bool bShadow);
1029 // --> OD 2007-06-04 #i77805#
1030 // new return value indicates, if an inherited outline numbering is suppressed
1031 virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt);
1032 // <--
1034 unsigned int GetHdFtIndex() const { return mnHdFtIndex; }
1035 void SetHdFtIndex(unsigned int nHdFtIndex) { mnHdFtIndex = nHdFtIndex; }
1036 void IncrementHdFtIndex() { ++mnHdFtIndex; }
1038 static long GetDTTM( const DateTime& rDT );
1040 /// Convert the SVX numbering type to id
1041 static BYTE GetNumId( USHORT eNumType );
1043 /// Guess the script (asian/western).
1044 virtual bool CollapseScriptsforWordOk( USHORT nScript, USHORT nWhich );
1046 USHORT DupNumRuleWithLvlStart(const SwNumRule *pRule,BYTE nLvl,USHORT nVal);
1048 SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const;
1050 /// Nasty swap for bidi if neccessary
1051 bool MiserableRTLFrmFmtHack(SwTwips &rLeft, SwTwips &rRight,
1052 const sw::Frame &rFrmFmt);
1054 void InsUInt16( UINT16 n ) { SwWW8Writer::InsUInt16( *pO, n ); }
1055 void InsUInt32( UINT32 n ) { SwWW8Writer::InsUInt32( *pO, n ); }
1056 void InsAsString16( const String& rStr )
1057 { SwWW8Writer::InsAsString16( *pO, rStr ); }
1058 void InsAsString8( const String& rStr, rtl_TextEncoding eCodeSet )
1059 { SwWW8Writer::InsAsString8( *pO, rStr, eCodeSet ); }
1060 void WriteStringAsPara( const String& rTxt, USHORT nStyleId = 0 );
1062 /// Setup the exporter.
1063 WW8Export( SwWW8Writer *pWriter,
1064 SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam,
1065 bool bIsWW8 );
1066 virtual ~WW8Export();
1068 virtual void DoComboBox(const rtl::OUString &rName,
1069 const rtl::OUString &rHelp,
1070 const rtl::OUString &ToolTip,
1071 const rtl::OUString &rSelected,
1072 com::sun::star::uno::Sequence<rtl::OUString> &rListItems);
1074 virtual void DoFormText(const SwInputField * pFld);
1076 void GetCurrentItems(WW8Bytes &rItems) const;
1078 /// Write the data of the form field
1079 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark );
1080 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark );
1082 /// Fields.
1083 WW8_WrPlcFld* CurrentFieldPlc() const;
1085 SwWW8Writer& GetWriter() const { return *m_pWriter; }
1086 SvStream& Strm() const { return m_pWriter->Strm(); }
1088 /// Remember some of the memebers so that we can recurse in WriteText().
1089 virtual void SaveData( ULONG nStt, ULONG nEnd );
1091 /// Restore what was saved in SaveData().
1092 virtual void RestoreData();
1094 /// Output the actual headers and footers.
1095 virtual void WriteHeadersFooters( BYTE nHeadFootFlags,
1096 const SwFrmFmt& rFmt, const SwFrmFmt& rLeftFmt, const SwFrmFmt& rFirstPageFmt,
1097 BYTE nBreakCode);
1099 protected:
1100 /// Output SwGrfNode
1101 virtual void OutputGrfNode( const SwGrfNode& );
1103 /// Output SwOLENode
1104 virtual void OutputOLENode( const SwOLENode& );
1106 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFmt* pFmt, ULONG nLnNum );
1108 private:
1109 /// No copying.
1110 WW8Export(const WW8Export&);
1111 /// No copying.
1112 WW8Export& operator=(const WW8Export&);
1115 class WW8_WrPlcSubDoc // Doppel-Plc fuer Foot-/Endnotes und Postits
1117 private:
1118 //No copying
1119 WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&);
1120 WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&);
1121 protected:
1122 SvULongs aCps; // PTRARR CP-Pos der Verweise
1123 SvPtrarr aCntnt; // PTRARR von SwFmtFtn/PostIts/..
1124 WW8_WrPlc0* pTxtPos; // Pos der einzelnen Texte
1126 WW8_WrPlcSubDoc();
1127 virtual ~WW8_WrPlcSubDoc();
1129 bool WriteGenericTxt( WW8Export& rWrt, BYTE nTTyp, WW8_CP& rCount );
1130 void WriteGenericPlc( WW8Export& rWrt, BYTE nTTyp, WW8_FC& rTxtStt,
1131 sal_Int32& rTxtCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const;
1133 virtual const SvULongs* GetShapeIdArr() const;
1136 // Doppel-Plc fuer Footnotes/Endnotes
1137 class WW8_WrPlcFtnEdn : public WW8_WrPlcSubDoc
1139 private:
1140 BYTE nTyp;
1142 //No copying
1143 WW8_WrPlcFtnEdn(const WW8_WrPlcFtnEdn&);
1144 WW8_WrPlcFtnEdn& operator=(WW8_WrPlcFtnEdn &);
1145 public:
1146 WW8_WrPlcFtnEdn( BYTE nTTyp ) : nTyp( nTTyp ) {}
1148 bool WriteTxt( WW8Export& rWrt );
1149 void WritePlc( WW8Export& rWrt ) const;
1151 void Append( WW8_CP nCp, const SwFmtFtn& rFtn );
1154 class WW8_WrPlcPostIt : public WW8_WrPlcSubDoc // Doppel-Plc fuer PostIts
1156 private:
1157 //No copying
1158 WW8_WrPlcPostIt(const WW8_WrPlcPostIt&);
1159 WW8_WrPlcPostIt& operator=(WW8_WrPlcPostIt&);
1160 public:
1161 WW8_WrPlcPostIt() {}
1163 void Append( WW8_CP nCp, const SwPostItField& rPostIt );
1164 bool WriteTxt( WW8Export& rWrt );
1165 void WritePlc( WW8Export& rWrt ) const;
1168 class WW8_WrPlcTxtBoxes : public WW8_WrPlcSubDoc // Doppel-Plc fuer Textboxen
1169 { // Rahmen/DrawTextboxes!
1170 private:
1171 BYTE nTyp;
1172 SvULongs aShapeIds; // VARARR of ShapeIds for the SwFrmFmts
1173 virtual const SvULongs* GetShapeIdArr() const;
1175 //No copying
1176 WW8_WrPlcTxtBoxes(const WW8_WrPlcTxtBoxes&);
1177 WW8_WrPlcTxtBoxes& operator=(WW8_WrPlcTxtBoxes&);
1178 public:
1179 WW8_WrPlcTxtBoxes( BYTE nTTyp ) : nTyp( nTTyp ) {}
1181 bool WriteTxt( WW8Export& rWrt );
1182 void WritePlc( WW8Export& rWrt ) const;
1183 void Append( const SdrObject& rObj, UINT32 nShapeId );
1184 USHORT Count() const { return aCntnt.Count(); }
1185 USHORT GetPos( const VoidPtr& p ) const { return aCntnt.GetPos( p ); }
1188 typedef WW8_WrFkp* WW8_FkpPtr; // Plc fuer Chpx und Papx ( incl PN-Plc )
1189 SV_DECL_PTRARR( WW8_WrFkpPtrs, WW8_FkpPtr, 4, 4 )
1191 class WW8_WrPlcPn // Plc fuer Page Numbers
1193 private:
1194 WW8Export& rWrt;
1195 WW8_WrFkpPtrs aFkps; // PTRARR
1196 USHORT nFkpStartPage;
1197 ePLCFT ePlc;
1198 bool bWrtWW8; // Fuer Writererkennung
1199 USHORT nMark;
1201 //No copying
1202 WW8_WrPlcPn(const WW8_WrPlcPn&);
1203 WW8_WrPlcPn& operator=(const WW8_WrPlcPn&);
1204 public:
1205 WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc );
1206 ~WW8_WrPlcPn();
1207 void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const BYTE* pSprms = 0);
1208 void WriteFkps();
1209 void WritePlc();
1210 BYTE *CopyLastSprms(BYTE &rLen);
1213 // class WW8_WrPlc1 ist erstmal nur fuer Felder
1214 class WW8_WrPlc1
1216 private:
1217 SvULongs aPos; // PTRARR von CPs
1218 BYTE* pData; // Inhalte ( Strukturen )
1219 ULONG nDataLen;
1220 USHORT nStructSiz;
1222 //No copying
1223 WW8_WrPlc1(const WW8_WrPlc1&);
1224 WW8_WrPlc1& operator=(const WW8_WrPlc1&);
1225 protected:
1226 USHORT Count() const { return aPos.Count(); }
1227 void Write( SvStream& rStrm );
1228 WW8_CP Prev() const;
1229 public:
1230 WW8_WrPlc1( USHORT nStructSz );
1231 ~WW8_WrPlc1();
1232 void Append( WW8_CP nCp, const void* pData );
1233 void Finish( ULONG nLastCp, ULONG nStartCp );
1236 // class WW8_WrPlcFld ist fuer Felder
1237 class WW8_WrPlcFld : public WW8_WrPlc1
1239 private:
1240 BYTE nTxtTyp;
1241 USHORT nResults;
1243 //No copying
1244 WW8_WrPlcFld(const WW8_WrPlcFld&);
1245 WW8_WrPlcFld& operator=(const WW8_WrPlcFld&);
1246 public:
1247 WW8_WrPlcFld( USHORT nStructSz, BYTE nTTyp )
1248 : WW8_WrPlc1( nStructSz ), nTxtTyp( nTTyp ), nResults(0)
1250 bool Write( WW8Export& rWrt );
1251 void ResultAdded() { ++nResults; }
1252 USHORT ResultCount() const { return nResults; }
1255 class WW8_WrMagicTable : public WW8_WrPlc1
1257 private:
1258 //No copying
1259 WW8_WrMagicTable(const WW8_WrMagicTable&);
1260 WW8_WrMagicTable& operator=(const WW8_WrMagicTable&);
1261 public:
1262 WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);}
1263 void Append( WW8_CP nCp, ULONG nData );
1264 bool Write( WW8Export& rWrt );
1267 class GraphicDetails
1269 public:
1270 sw::Frame maFly; // Umgebende FlyFrms dazu
1271 ULONG mnPos; // FilePos der Grafiken
1272 UINT16 mnWid; // Breite der Grafiken
1273 UINT16 mnHei; // Hoehe der Grafiken
1275 GraphicDetails(const sw::Frame &rFly, UINT16 nWid, UINT16 nHei)
1276 : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei)
1278 GraphicDetails& operator=(const GraphicDetails& rOther);
1280 bool operator==(const GraphicDetails& rIn) const
1282 return (
1283 (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) &&
1284 (maFly.RefersToSameFrameAs(rIn.maFly))
1289 // class SwWW8WrGrf sammelt Grafiken und gibt sie aus
1290 class SwWW8WrGrf
1292 private:
1293 /// for access to the variables
1294 WW8Export& rWrt;
1296 std::vector<GraphicDetails> maDetails;
1297 typedef std::vector<GraphicDetails>::iterator myiter;
1298 USHORT mnIdx; // Index in File-Positionen
1300 void WritePICFHeader(SvStream& rStrm, const sw::Frame &rFly,
1301 UINT16 mm, UINT16 nWidth, UINT16 nHeight,
1302 const SwAttrSet* pAttrSet = 0);
1303 void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem);
1304 void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd,
1305 const sw::Frame &rFly, UINT16 nWidth, UINT16 nHeight);
1307 //No copying
1308 SwWW8WrGrf(const SwWW8WrGrf&);
1309 SwWW8WrGrf& operator=(const SwWW8WrGrf&);
1310 public:
1311 SwWW8WrGrf( WW8Export& rW ) : rWrt( rW ), mnIdx( 0 ) {}
1312 void Insert(const sw::Frame &rFly);
1313 void Write();
1314 ULONG GetFPos()
1315 { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
1318 /** The class MSWordAttrIter is a helper class to build the Fkp.chpx.
1319 This class may be overloaded for output the SwTxtAttrs and the
1320 EditEngineTxtAttrs.
1322 class MSWordAttrIter
1324 private:
1325 MSWordAttrIter* pOld;
1326 //No copying
1327 MSWordAttrIter(const MSWordAttrIter&);
1328 MSWordAttrIter& operator=(const MSWordAttrIter&);
1329 protected:
1330 MSWordExportBase& m_rExport;
1331 public:
1332 MSWordAttrIter( MSWordExportBase& rExport );
1333 virtual ~MSWordAttrIter();
1335 virtual const SfxPoolItem* HasTextItem( USHORT nWhich ) const = 0;
1336 virtual const SfxPoolItem& GetItem( USHORT nWhich ) const = 0;
1339 /// Class to collect and output the styles table.
1340 class MSWordStyles
1342 MSWordExportBase& m_rExport;
1343 SwFmt** pFmtA;
1344 USHORT nUsedSlots;
1346 /// Create the style table, called from the constructor.
1347 void BuildStylesTable();
1349 /// Get slot number during building the style table.
1350 USHORT BuildGetSlot( const SwFmt& rFmt );
1352 /// Return information about one style.
1353 void GetStyleData( SwFmt* pFmt, bool& bFmtColl, USHORT& nBase, USHORT& nNext );
1355 /// Outputs attributes of one style.
1356 void WriteProperties( const SwFmt* pFmt, bool bPap, USHORT nPos, bool bInsDefCharSiz );
1358 USHORT GetWWId( const SwFmt& rFmt ) const;
1360 void SetStyleDefaults( const SwFmt& rFmt, bool bPap );
1362 /// Outputs one style - called (in a loop) from OutputStylesTable().
1363 void OutputStyle( SwFmt* pFmt, USHORT nPos );
1365 // No copying
1366 MSWordStyles( const MSWordStyles& );
1367 MSWordStyles& operator=( const MSWordStyles& );
1369 public:
1370 MSWordStyles( MSWordExportBase& rExport );
1371 ~MSWordStyles();
1373 /// Output the styles table.
1374 void OutputStylesTable();
1376 /// Get id of the style (rFmt).
1377 USHORT GetSlot( const SwFmt& rFmt ) const;
1379 SwFmt* GetSwFmt() { return (*pFmtA); }
1382 sal_Int16 GetWordFirstLineOffset(const SwNumFmt &rFmt);
1383 //A bit of a bag on the side for now
1384 String FieldString(ww::eField eIndex);
1385 String BookmarkToWord(const String &rBookmark);
1387 class WW8SHDLong
1389 sal_uInt32 m_cvFore;
1390 sal_uInt32 m_cvBack;
1391 sal_uInt16 m_ipat;
1393 public:
1394 WW8SHDLong() : m_cvFore(0), m_cvBack(0), m_ipat(0) {}
1395 virtual ~WW8SHDLong() {}
1397 void Write(WW8Export & rExport);
1398 void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; }
1399 void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; }
1400 void setIPat(sal_uInt16 ipat) { m_ipat = ipat; }
1403 /// For the output of sections.
1404 struct WW8_PdAttrDesc
1406 BYTE* pData;
1407 USHORT nLen;
1408 WW8_FC nSepxFcPos;
1411 #endif // _WRTWW8_HXX
1413 /* vi:set tabstop=4 shiftwidth=4 expandtab: */