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