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