android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / filter / ww8 / wrtww8.hxx
blob3aa39a2994b81bc31edc02a50e0b1861bb189422
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
23 #include <sot/storage.hxx>
24 #include <svl/nfkeytab.hxx>
25 #include <tools/solar.h>
26 #include <tools/gen.hxx>
27 #include <editeng/editdata.hxx>
28 #include <filter/msfilter/ww8fields.hxx>
29 #include <filter/msfilter/msoleexp.hxx>
31 #include <shellio.hxx>
33 #include "ww8struc.hxx"
34 #include "ww8scan.hxx"
35 #include "types.hxx"
36 #include "writerhelper.hxx"
37 #include <msfilter.hxx>
38 #include <expfld.hxx>
39 #include "WW8TableInfo.hxx"
40 #include <calbck.hxx>
41 #include <IDocumentRedlineAccess.hxx>
43 #include <vcl/graph.hxx>
45 #include <optional>
46 #include <o3tl/typed_flags_set.hxx>
47 #include <o3tl/sorted_vector.hxx>
49 #include <cstddef>
50 #include <memory>
51 #include <map>
52 #include <string_view>
53 #include <vector>
54 #include <unordered_map>
57 class SvxBrushItem;
58 class EditTextObject;
60 // some forward declarations
61 class SwWW8AttrIter;
62 namespace msfilter
64 class MSCodec_Std97;
67 namespace editeng { class SvxBorderLine; }
69 class AttributeOutputBase;
70 class DocxAttributeOutput;
71 class RtfAttributeOutput;
72 class BitmapPalette;
73 class SwEscherEx;
74 class DateTime;
75 namespace vcl { class Font; }
76 class MSWordExportBase;
77 class SdrObject;
78 class SdrTextObj;
79 class SfxItemSet;
80 class SvStream;
81 class SvxFontItem;
82 class SvxBoxItem;
83 class SwAttrSet;
84 class SwCharFormat;
85 class SwContentNode;
86 class SwField;
87 class SwFormat;
88 class SwFormatContent;
89 class SwFormatFootnote;
90 class SwFrameFormat;
91 class SwGrfNode;
92 class SwNumFormat;
93 class SwNumRule;
94 class SwNumRuleTable;
95 class SwPageDesc;
96 class SwFormatPageDesc;
97 class SwOLENode;
98 class SwPostItField;
99 class SwRedlineData;
100 class SwSectionFormat;
101 class SwSectionNode;
102 class SwTableNode;
103 class SwTOXType;
104 class SwTextFormatColl;
105 class SwTextNode;
106 class SwWW8WrGrf;
107 class SwWW8Writer;
108 class MSWordStyles;
109 class WW8AttributeOutput;
110 class WW8Export;
111 class MSWordAttrIter;
112 class WW8_WrFkp;
113 class WW8_WrPlc0;
114 class WW8_WrPlc1;
115 class WW8_WrPlcField;
116 class WW8_WrMagicTable;
117 class WW8_WrPlcFootnoteEdn;
118 class WW8_WrPlcPn;
119 class WW8_WrPlcAnnotations;
120 class WW8_WrtFactoids;
121 class MSWordSections;
122 class WW8_WrPlcTextBoxes;
123 class WW8_WrPct; // administration
124 class WW8_WrtBookmarks;
125 class WW8_WrtRedlineAuthor;
126 class SwMSConvertControls;
127 class WW8_WrPc;
128 struct WW8_PdAttrDesc;
129 class SvxBrushItem;
130 namespace sw::mark { class IFieldmark; }
131 namespace com::sun::star::embed { class XEmbeddedObject; }
133 typedef std::map<const css::embed::XEmbeddedObject*, sal_Int32> WW8OleMap;
134 typedef o3tl::sorted_vector< sal_Int32 > SwSoftPageBreakList;
136 #define GRF_MAGIC_1 0x12 // 3 magic bytes for PicLocFc attribute
137 #define GRF_MAGIC_2 0x34
138 #define GRF_MAGIC_3 0x56
139 #define GRF_MAGIC_321 0x563412L
141 #define OLE_PREVIEW_AS_EMF //If we want to export ole2 previews as emf in ww8+
143 enum class FieldFlags : sal_uInt8 // for InsertField- Method
145 NONE = 0x00,
146 Start = 0x01,
147 CmdStart = 0x02,
148 CmdEnd = 0x04,
149 End = 0x10,
150 Close = 0x20,
151 All = 0x37
153 namespace o3tl {
154 template<> struct typed_flags<FieldFlags> : is_typed_flags<FieldFlags, 0x37> {};
157 enum TextTypes //enums for TextTypes
159 TXT_MAINTEXT = 0, /*TXT_FTNEDN = 1,*/ TXT_HDFT = 2, TXT_FTN = 3,
160 TXT_EDN = 4, TXT_ATN = 5, TXT_TXTBOX = 6, TXT_HFTXTBOX= 7
164 enum to state the present state of the fly
166 enum FlyProcessingState
168 FLY_NONE,
169 FLY_PROCESSED,
170 FLY_POSTPONED,
171 FLY_NOT_PROCESSED
174 struct WW8_SepInfo
176 const SwPageDesc* pPageDesc;
177 const SwSectionFormat* pSectionFormat;
178 const SwNode* pPDNd;
179 sal_uLong nLnNumRestartNo;
180 ::std::optional<sal_uInt16> oPgRestartNo;
181 bool bIsFirstParagraph;
183 WW8_SepInfo( const SwPageDesc* pPD, const SwSectionFormat* pFormat,
184 sal_uLong nLnRestart, ::std::optional<sal_uInt16> oPgRestart = std::nullopt,
185 const SwNode* pNd = nullptr, bool bIsFirstPara = false )
186 : pPageDesc( pPD ), pSectionFormat( pFormat ), pPDNd( pNd ),
187 nLnNumRestartNo( nLnRestart ), oPgRestartNo( oPgRestart ),
188 bIsFirstParagraph( bIsFirstPara )
191 bool IsProtected() const;
194 /// Class to collect and output the sections/headers/footers.
195 // Plc for PageDescs -> Sepx ( Section Extensions )
196 class MSWordSections
198 protected:
199 bool mbDocumentIsProtected;
200 std::vector<WW8_SepInfo> m_aSects;
202 void CheckForFacinPg( const WW8Export& rWrt ) const;
203 void NeedsDocumentProtected(const WW8_SepInfo &rInfo);
205 //No copy, no assign
206 MSWordSections( const MSWordSections& );
207 MSWordSections& operator=( const MSWordSections& );
208 public:
209 explicit MSWordSections( MSWordExportBase& rExport );
210 virtual ~MSWordSections();
212 virtual bool HeaderFooterWritten();
214 void AppendSection( const SwPageDesc* pPd,
215 const SwSectionFormat* pSectionFormat,
216 sal_uLong nLnNumRestartNo,
217 bool bIsFirstParagraph = false );
218 void AppendSection( const SwFormatPageDesc& rPd,
219 const SwNode& rNd,
220 const SwSectionFormat* pSectionFormat,
221 sal_uLong nLnNumRestartNo );
223 /// Number of columns based on the most recent WW8_SepInfo.
224 sal_uInt16 CurrentNumberOfColumns( const SwDoc &rDoc ) const;
226 /// Number of columns of the provided WW8_SepInfo.
227 static const SwFormatCol& GetFormatCol(const SwDoc &rDoc, const WW8_SepInfo& rInfo);
229 bool DocumentIsProtected() const { return mbDocumentIsProtected; }
231 /// The most recent WW8_SepInfo.
232 const WW8_SepInfo* CurrentSectionInfo();
234 static void SetHeaderFlag( sal_uInt8& rHeadFootFlags, const SwFormat& rFormat,
235 sal_uInt8 nFlag );
236 static void SetFooterFlag( sal_uInt8& rHeadFootFlags, const SwFormat& rFormat,
237 sal_uInt8 nFlag );
239 /// Should we output borders?
240 static bool HasBorderItem( const SwFormat& rFormat );
243 class WW8_WrPlcSepx : public MSWordSections
245 std::vector<WW8_CP> m_aCps;
246 std::vector< std::shared_ptr<WW8_PdAttrDesc> > m_SectionAttributes;
247 // hack to prevent adding sections in endnotes
248 bool m_bHeaderFooterWritten;
249 std::unique_ptr<WW8_WrPlc0> m_pTextPos; // Position of the headers/footers
251 WW8_WrPlcSepx( const WW8_WrPlcSepx& ) = delete;
252 WW8_WrPlcSepx& operator=( const WW8_WrPlcSepx& ) = delete;
254 public:
255 explicit WW8_WrPlcSepx( MSWordExportBase& rExport );
256 virtual ~WW8_WrPlcSepx() override;
258 virtual bool HeaderFooterWritten() override; // override
260 void AppendSep( WW8_CP nStartCp,
261 const SwPageDesc* pPd,
262 const SwSectionFormat* pSectionFormat,
263 sal_uLong nLnNumRestartNo );
264 void AppendSep( WW8_CP nStartCp, const SwFormatPageDesc& rPd,
265 const SwNode& rNd,
266 const SwSectionFormat* pSectionFormat,
267 sal_uLong nLnNumRestartNo );
268 void Finish( WW8_CP nEndCp ) { m_aCps.push_back( nEndCp ); }
270 bool WriteKFText( WW8Export& rWrt );
271 void WriteSepx( SvStream& rStrm ) const;
272 void WritePlcSed( WW8Export& rWrt ) const;
273 void WritePlcHdd( WW8Export& rWrt ) const;
275 private:
276 void WriteFootnoteEndText( WW8Export& rWrt, sal_uLong nCpStt );
277 public:
278 void OutHeaderFooter(WW8Export& rWrt, bool bHeader,
279 const SwFormat& rFormat, sal_uLong& rCpPos, sal_uInt8 nHFFlags, sal_uInt8 nFlag, sal_uInt8 nBreakCode);
282 // class WW8_WrPct to construct the piece table
283 class WW8_WrPct
285 std::vector<std::unique_ptr<WW8_WrPc>> m_Pcts;
286 WW8_FC m_nOldFc;
287 public:
288 explicit WW8_WrPct(WW8_FC nStartFc);
289 ~WW8_WrPct();
290 void AppendPc(WW8_FC nStartFc);
291 void WritePc( WW8Export& rWrt );
292 void SetParaBreak();
293 WW8_CP Fc2Cp( sal_uLong nFc ) const;
296 /// Collects and outputs fonts.
297 class wwFont
299 //In some future land the stream could be converted to a nice stream interface
300 //and we could have harmony
301 private:
302 sal_uInt8 maWW8_FFN[6] = {};
303 OUString msFamilyNm;
304 OUString msAltNm;
305 bool mbAlt;
306 FontPitch mePitch;
307 FontFamily meFamily;
308 rtl_TextEncoding meChrSet;
309 public:
310 wwFont( std::u16string_view rFamilyName, FontPitch ePitch, FontFamily eFamily,
311 rtl_TextEncoding eChrSet);
312 void Write( SvStream *pTableStram ) const;
313 void WriteDocx( DocxAttributeOutput* rAttrOutput ) const;
314 void WriteRtf( const RtfAttributeOutput* rAttrOutput ) const;
315 OUString const & GetFamilyName() const { return msFamilyNm; }
316 friend bool operator < (const wwFont &r1, const wwFont &r2);
319 class wwFontHelper
321 private:
322 /// Keep track of fonts that need to be exported.
323 std::map<wwFont, sal_uInt16> maFonts;
325 /// Convert from fast insertion map to linear vector in the order that we want to write.
326 std::vector< const wwFont* > AsVector() const;
328 public:
329 wwFontHelper() : m_bLoadAllFonts(false) {}
330 /// rDoc used only to get the initial standard font(s) in use.
331 void InitFontTable(const SwDoc& rDoc);
332 sal_uInt16 GetId(const SvxFontItem& rFont);
333 sal_uInt16 GetId(const wwFont& rFont);
334 void WriteFontTable( SvStream *pTableStream, WW8Fib& pFib );
335 void WriteFontTable( DocxAttributeOutput& rAttrOutput );
336 void WriteFontTable( const RtfAttributeOutput& rAttrOutput );
338 /// If true, all fonts are loaded before processing the document.
339 bool m_bLoadAllFonts: 1;
342 class DrawObj
344 public:
345 WW8_CP mnCp; // CP-Pos of references
346 sal_uInt32 mnShapeId; // ShapeId for the SwFrameFormats
347 ww8::Frame maContent; // the frame itself
348 Point maParentPos; // Points
349 sal_Int32 mnThick; // Border Thicknesses
350 SvxFrameDirection mnDirection; // If BiDi or not
351 unsigned int mnHdFtIndex; // 0 for main text, +1 for each subsequent
352 // msword hd/ft
354 DrawObj(const ww8::Frame &rContent, WW8_CP nCp, Point aParentPos, SvxFrameDirection nDir,
355 unsigned int nHdFtIndex)
356 : mnCp(nCp), mnShapeId(0), maContent(rContent), maParentPos(aParentPos),
357 mnThick(0), mnDirection(nDir), mnHdFtIndex(nHdFtIndex) {}
358 void SetShapeDetails(sal_uInt32 nId, sal_Int32 nThick);
361 typedef std::vector<DrawObj> DrawObjVector;
362 typedef std::vector<DrawObj *> DrawObjPointerVector;
364 class PlcDrawObj // PC for DrawObjects and Text-/OLE-/GRF-Boxes
366 private:
367 DrawObjVector maDrawObjs; // vector of drawobjs
368 protected:
369 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
370 sal_uInt32 nLen) const = 0;
371 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const = 0;
372 public:
373 PlcDrawObj() {}
374 void WritePlc( WW8Export& rWrt ) const;
375 bool Append( WW8Export const &, WW8_CP nCp, const ww8::Frame& rFormat,
376 const Point& rNdTopLeft );
377 int size() { return maDrawObjs.size(); };
378 DrawObjVector &GetObjArr() { return maDrawObjs; }
379 virtual ~PlcDrawObj();
380 private:
381 PlcDrawObj(const PlcDrawObj&) = delete;
382 PlcDrawObj& operator=(const PlcDrawObj&) = delete;
385 class MainTextPlcDrawObj : public PlcDrawObj
387 public:
388 MainTextPlcDrawObj() {}
389 private:
390 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
391 sal_uInt32 nLen) const override;
392 virtual WW8_CP GetCpOffset(const WW8Fib &) const override;
393 private:
394 MainTextPlcDrawObj(const MainTextPlcDrawObj&) = delete;
395 MainTextPlcDrawObj& operator=(const MainTextPlcDrawObj&) = delete;
398 class HdFtPlcDrawObj : public PlcDrawObj
400 public:
401 HdFtPlcDrawObj() {}
402 private:
403 virtual void RegisterWithFib(WW8Fib &rFib, sal_uInt32 nStart,
404 sal_uInt32 nLen) const override;
405 virtual WW8_CP GetCpOffset(const WW8Fib &rFib) const override;
406 private:
407 HdFtPlcDrawObj(const HdFtPlcDrawObj&) = delete;
408 HdFtPlcDrawObj& operator=(const HdFtPlcDrawObj&) = delete;
411 typedef std::pair<OUString, SwNodeOffset> aBookmarkPair;
413 class WW8_WrtRedlineAuthor : public sw::util::WrtRedlineAuthor
415 public:
416 virtual void Write(Writer &rWrt) override;
419 /** Structure that is used to save some of the WW8Export/DocxExport data.
421 It is used to be able to recurse inside of the WW8Export/DocxExport (eg.
422 for the needs of the tables) - you need to tall WriteText() from there with
423 new values of PaM etc.
425 It must contain all the stuff that might be saved either in WW8Export or in
426 DocxExport, because it makes no sense to do it abstract, and specialize it
427 for each of the cases. If you implement other *Export, just add the needed
428 members here, and store them in the appropriate SaveData() method.
430 struct MSWordSaveData
432 Point* pOldFlyOffset;
433 RndStdIds eOldAnchorType;
434 std::unique_ptr<ww::bytes> pOOld; ///< WW8Export only
435 std::shared_ptr<SwUnoCursor> pOldPam;
436 SwPaM* pOldEnd;
437 SwNodeOffset nOldStart, nOldEnd;
438 const ww8::Frame* pOldFlyFormat;
439 const SwPageDesc* pOldPageDesc;
441 bool bOldWriteAll : 1; ///< WW8Export only
442 bool bOldOutTable : 1;
443 bool bOldFlyFrameAttrs : 1;
444 bool bOldStartTOX : 1;
445 bool bOldInWriteTOX : 1;
446 // m_bOutPageDescs does not have to be saved in MSWordExportBase::SaveData
447 // since it is only modified when outputting special texts.
450 /// Base class for WW8Export and DocxExport
451 class MSWordExportBase
453 public:
454 wwFontHelper m_aFontHelper;
455 std::vector<SwNodeOffset> m_aChapterFieldLocs;
456 OUString m_aMainStg;
457 std::vector<const SwTOXType*> m_aTOXArr;
458 const SfxItemSet* m_pISet; // for double attributes
459 const SwFrameFormat* m_pFirstPageFormat = nullptr;
460 std::unique_ptr<WW8_WrPct> m_pPiece; // Pointer to Piece-Table
461 std::unique_ptr<SwNumRuleTable> m_pUsedNumTable; // all used NumRules
462 /// overriding numdef index -> (existing numdef index, abstractnumdef index)
463 std::map<size_t, std::pair<size_t, size_t>> m_OverridingNums;
464 /// list-id -> abstractnumdef index
465 std::map<OUString, size_t> m_Lists;
467 /// Map of maps for list levels overrides
468 /// listid -> level number -> restart value
469 std::map < size_t, std::map<size_t, size_t> > m_ListLevelOverrides;
471 const SwTextNode *m_pTopNodeOfHdFtPage; ///< Top node of host page when in hd/ft
472 std::stack< sal_Int32 > m_aCurrentCharPropStarts; ///< To remember the position in a run.
473 std::unique_ptr<WW8_WrtBookmarks> m_pBkmks;
474 std::unique_ptr<WW8_WrtRedlineAuthor> m_pRedlAuthors;
475 std::shared_ptr<NfKeywordTable> m_pKeyMap;
476 std::optional<SvxMSExportOLEObjects> m_oOLEExp;
477 std::unique_ptr<SwMSConvertControls> m_pOCXExp;
478 WW8OleMap m_aOleMap; // To remember all already exported ole objects
479 ww8::WW8TableInfo::Pointer_t m_pTableInfo;
481 sal_uInt16 m_nCharFormatStart;
482 sal_uInt16 m_nFormatCollStart;
483 sal_uInt16 m_nStyleBeforeFly; ///< style number of the node
484 ///< to which the Fly is connected
485 sal_uInt16 m_nLastFormatId; ///< Style of last TextNode in normal range
486 sal_uInt16 m_nUniqueList; ///< current number for creating unique list names
487 unsigned int m_nHdFtIndex;
489 RedlineFlags m_nOrigRedlineFlags; ///< Remember the original redline mode
490 bool m_bOrigShowChanges; ///< Remember the original Show Changes mode
492 public:
493 /* implicit bookmark vector containing pairs of node indexes and bookmark names */
494 std::vector<aBookmarkPair> m_aImplicitBookmarks;
495 std::unordered_map<OUString, OUString> m_TOXMarkBookmarksByURL;
496 std::unordered_map<SwTOXMark const*, OUString> m_TOXMarkBookmarksByTOXMark;
497 ww8::Frames m_aFrames; // The floating frames in this document
498 const SwPageDesc *m_pCurrentPageDesc;
499 const SwPageDesc* m_pPreviousSectionPageDesc;
500 bool m_bFirstTOCNodeWithSection;
501 std::unique_ptr<WW8_WrPlcPn> m_pPapPlc;
502 std::unique_ptr<WW8_WrPlcPn> m_pChpPlc;
503 MSWordAttrIter* m_pChpIter;
504 std::unique_ptr<MSWordStyles> m_pStyles;
505 std::unique_ptr<WW8_WrPlcAnnotations> m_pAtn;
506 std::unique_ptr<WW8_WrtFactoids> m_pFactoids;
507 std::unique_ptr<WW8_WrPlcTextBoxes> m_pTextBxs, m_pHFTextBxs;
509 struct LinkedTextboxInfo //help analyze textbox flow links
511 sal_Int32 nId;
512 sal_Int32 nSeq;
513 OUString sNextChain;
514 OUString sPrevChain;
515 LinkedTextboxInfo(): nId(0), nSeq(0) {}
517 std::map<OUString,LinkedTextboxInfo> m_aLinkedTextboxesHelper;
518 bool m_bLinkedTextboxesHelperInitialized = false;
519 sal_Int32 m_nLinkedTextboxesChainId=0;
521 const ww8::Frame *m_pParentFrame; // If set we are exporting content inside
522 // a frame, e.g. a graphic node
524 Point* m_pFlyOffset; // for adjusting of character-bound Fly in the Writer,
525 RndStdIds m_eNewAnchorType; // that is paragraph-bound in the WW.
527 std::unique_ptr<WW8_WrPlcField> m_pFieldMain; // fields in MainText
528 std::unique_ptr<WW8_WrPlcField> m_pFieldHdFt; // fields in Header/Footer
529 std::unique_ptr<WW8_WrPlcField> m_pFieldFootnote; // fields in FootNotes
530 std::unique_ptr<WW8_WrPlcField> m_pFieldEdn; // fields in EndNotes
531 std::unique_ptr<WW8_WrPlcField> m_pFieldAtn; // fields in Annotations
532 std::unique_ptr<WW8_WrPlcField> m_pFieldTextBxs; // fields in textboxes
533 std::unique_ptr<WW8_WrPlcField> m_pFieldHFTextBxs; // fields in header/footer textboxes
534 std::unique_ptr<WW8_WrMagicTable> m_pMagicTable; // keeps track of table cell positions, and
535 // marks those that contain graphics,
536 // which is required to make word display
537 // graphics inside tables
538 std::unique_ptr<SwWW8WrGrf> m_pGrf;
539 const SwAttrSet* m_pStyAttr; // StyleAttr for Tabs
540 const sw::BroadcastingModify* m_pOutFormatNode; // write Format or Node
541 const SwFormat *m_pCurrentStyle; // iff bStyDef=true, then this store the current style
543 std::unique_ptr<MainTextPlcDrawObj> m_pSdrObjs; // Draw-/Fly-Objects
544 std::unique_ptr<HdFtPlcDrawObj> m_pHFSdrObjs; // Draw-/Fly-Objects in header or footer
546 SwEscherEx* m_pEscher; // escher export class
547 // #i43447# - removed
548 // SwTwips nFlyWidth, nFlyHeight; // for adaptation of graphics
550 sal_uInt8 m_nTextTyp;
552 bool m_bStyDef : 1; // should Style be written?
553 bool m_bBreakBefore : 1; // Breaks are being written 2 times
554 bool m_bOutKF : 1; // Header/Footer texts are being written
555 bool m_bOutFlyFrameAttrs : 1; // Frame-attr of Flys are being written
556 bool m_bOutPageDescs : 1; ///< PageDescs (section properties) are being written
557 bool m_bOutFirstPage : 1; // write Attrset of FirstPageDesc
558 bool m_bOutTable : 1; // table is being written
559 // ( is reset e.g. for Flys in a table )
560 bool m_bOutGrf : 1; // graphics are being written
561 bool m_bInWriteEscher : 1; // in write textboxes
562 bool m_bStartTOX : 1; // true: a TOX is started
563 bool m_bInWriteTOX : 1; // true: all content are in a TOX
564 bool m_bFootnoteAtTextEnd : 1; // true: all FTN at Textend
565 bool m_bEndAtTextEnd : 1; // true: all END at Textend
566 bool m_bHasHdr : 1;
567 bool m_bHasFtr : 1;
568 bool m_bSubstituteBullets : 1; // true: SubstituteBullet() gets called
569 bool m_bTabInTOC : 1; //true for TOC field flag 'w'
571 bool m_bHideTabLeaderAndPageNumbers : 1 ; // true: the 'z' field of TOC is set.
572 bool m_bExportModeRTF;
573 /// Is font size written already as part of the current character properties?
574 bool m_bFontSizeWritten;
575 bool m_bAddFootnoteTab; // only one aesthetic spacing tab per footnote
577 SwDoc& m_rDoc;
578 SwNodeOffset m_nCurStart, m_nCurEnd;
579 std::shared_ptr<SwUnoCursor> & m_pCurPam;
580 SwPaM *m_pOrigPam;
582 /// Stack to remember the nesting (see MSWordSaveData for more)
583 std::stack< MSWordSaveData > m_aSaveData;
585 /// Used to split the runs according to the bookmarks start and ends
586 typedef std::vector< ::sw::mark::IMark* > IMarkVector;
587 IMarkVector m_rSortedBookmarksStart;
588 IMarkVector m_rSortedBookmarksEnd;
589 IMarkVector m_rSortedAnnotationMarksStart;
590 IMarkVector m_rSortedAnnotationMarksEnd;
592 public:
593 /// The main function to export the document.
594 ErrCode ExportDocument( bool bWriteAll );
596 /// Iterate through the nodes and call the appropriate OutputNode() on them.
597 void WriteText();
599 /// Return whether currently exported node is in table.
600 bool IsInTable() const;
602 /// Set the pCurPam appropriately and call WriteText().
604 /// Used to export paragraphs in footnotes/endnotes/etc.
605 void WriteSpecialText( SwNodeOffset nStart, SwNodeOffset nEnd, sal_uInt8 nTTyp );
607 /// Export the pool items to attributes (through an attribute output class).
608 void ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 nScript, const SvxFontItem *pFont, bool bWriteCombChars = false );
610 /// Return the numeric id of the numbering rule
611 sal_uInt16 GetNumberingId( const SwNumRule& rNumRule );
613 /// Return the numeric id of the style.
614 sal_uInt16 GetId( const SwTextFormatColl& rColl ) const;
616 /// Return the numeric id of the style.
617 sal_uInt16 GetId( const SwCharFormat* pFormat ) const;
619 sal_uInt16 GetId( const SwTOXType& rTOXType );
621 /// Return the numeric id of the font (and add it to the font list if needed)
622 sal_uInt16 GetId( const SvxFontItem& rFont)
624 return m_aFontHelper.GetId(rFont);
626 /// @overload
627 void GetId( const wwFont& rFont)
629 m_aFontHelper.GetId(rFont);
632 const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const;
633 template<class T> const T& GetItem( TypedWhichId<T> nWhich ) const
635 return static_cast<const T&>(GetItem(sal_uInt16(nWhich)));
638 /// Find the reference.
639 bool HasRefToAttr(const OUString& rName);
640 bool HasRefToFootOrEndnote(const bool isEndNote, const sal_uInt16 nSeqNo);
642 /// Find the bookmark name.
643 OUString GetBookmarkName( sal_uInt16 nTyp, const OUString* pName, sal_uInt16 nSeqNo );
645 /// Use OutputItem() on an item set according to the parameters.
646 void OutputItemSet( const SfxItemSet& rSet, bool bPapFormat, bool bChpFormat, sal_uInt16 nScript, bool bExportParentItemSet );
648 SvxFrameDirection GetDefaultFrameDirection( ) const;
650 /// Right to left?
651 SvxFrameDirection TrueFrameDirection( const SwFrameFormat& rFlyFormat ) const;
653 /// Right to left?
654 SvxFrameDirection GetCurrentPageDirection() const;
656 /// In case of numbering restart.
658 /// List is set to restart at a particular value so for export make a
659 /// completely new list based on this one and export that instead,
660 /// which duplicates words behaviour in this respect.
661 sal_uInt16 DuplicateNumRule(const SwNumRule* pRule, sal_uInt8 nLevel, sal_uInt16 nVal);
662 SwNumRule * DuplicateNumRuleImpl(const SwNumRule *pRule);
664 /// check if a new abstractNum is needed for this list
665 sal_uInt16 DuplicateAbsNum(OUString const& rListId,
666 SwNumRule const& rAbstractRule);
669 /// Create a overriding numbering definition (if it does not yet exist)
670 /// @return index of the overriding numbering definition
671 sal_uInt16 OverrideNumRule(SwNumRule const& rExistingRule,
672 OUString const& rListId,
673 SwNumRule const& rAbstractRule);
675 /// Store list level overrides (restart of list)
676 void AddListLevelOverride(sal_uInt16 nListId,
677 sal_uInt16 nLevelNum,
678 sal_uInt16 nStartAt);
680 /// Access to the attribute output class.
681 virtual AttributeOutputBase& AttrOutput() const = 0;
683 /// Access to the sections/headers/footres.
684 virtual MSWordSections& Sections() const = 0;
686 /// Determines if the import filter already quoted fields or not.
687 virtual bool FieldsQuoted() const = 0;
689 /// Determines the Section Breaks are to be added for TOX Section
690 virtual bool AddSectionBreaksForTOX() const = 0;
692 /// Used to filter out attributes that can be e.g. written to .doc but not to .docx
693 virtual bool ignoreAttributeForStyleDefaults( sal_uInt16 /*nWhich*/ ) const { return false; }
695 /// If saving page break is preferred as a paragraph attribute (yes) or as a special character (no).
696 virtual bool PreferPageBreakBefore() const = 0;
698 /// Guess the script (asian/western).
700 /// Sadly word does not have two different sizes for asian font size and
701 /// western font size, it has two different fonts, but not sizes, so we
702 /// have to use our guess as to the script used and disable the export of
703 /// one type. The same occurs for font weight and posture (bold and
704 /// italic).
706 /// In addition WW7- has only one character language identifier while WW8+
707 /// has two
708 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) = 0;
710 virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pSwRedline = nullptr ) = 0;
712 virtual void AppendBookmark( const OUString& rName ) = 0;
714 virtual void AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen ) = 0;
716 virtual void AppendSmartTags(SwTextNode& /*rTextNode*/) { }
718 //For i120928,add this interface to export graphic of bullet
719 virtual void ExportGrfBullet(const SwTextNode& rNd) = 0;
721 // FIXME probably a hack...
722 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) = 0;
724 // FIXME definitely a hack, must not be here - it can't do anything
725 // sensible for docx
726 virtual void WriteChar( sal_Unicode c ) = 0;
728 /// Output attributes.
729 void OutputFormat( const SwFormat& rFormat, bool bPapFormat, bool bChpFormat, bool bFlyFormat = false );
731 /// Getter for pISet.
732 const SfxItemSet* GetCurItemSet() const { return m_pISet; }
734 /// Setter for pISet.
735 void SetCurItemSet( const SfxItemSet* pS ) { m_pISet = pS; }
737 /// Remember some of the members so that we can recurse in WriteText().
738 virtual void SaveData( SwNodeOffset nStt, SwNodeOffset nEnd );
740 /// Restore what was saved in SaveData().
741 virtual void RestoreData();
743 /// The return value indicates, if a follow page desc is written.
744 bool OutputFollowPageDesc( const SfxItemSet* pSet,
745 const SwTextNode* pNd );
747 /// Write header/footer text.
748 void WriteHeaderFooterText( const SwFormat& rFormat, bool bHeader);
750 /// Format of the section.
751 static const SwSectionFormat* GetSectionFormat( const SwNode& rNd );
753 /// Line number of the section start.
754 static sal_uLong GetSectionLineNo( const SfxItemSet* pSet, const SwNode& rNd );
756 /// Start new section.
757 void OutputSectionBreaks( const SfxItemSet *pSet, const SwNode& rNd, bool isCellOpen = false );
759 /// Write section properties.
761 /// pA is ignored for docx.
762 void SectionProperties( const WW8_SepInfo& rSectionInfo, WW8_PdAttrDesc* pA = nullptr );
764 /// Output the numbering table.
765 virtual void WriteNumbering() = 0;
767 /// Write static data of SwNumRule - LSTF
768 void NumberingDefinitions();
770 /// Write all Levels for all SwNumRules - LVLF
771 void AbstractNumberingDefinitions();
773 /// Write one numbering level
774 void NumberingLevel(SwNumRule const& rRule, sal_uInt8 nLvl);
776 // Convert the bullet according to the font.
777 void SubstituteBullet( OUString& rNumStr, rtl_TextEncoding& rChrSet,
778 OUString& rFontName ) const;
780 /// Setup the pA's info.
781 virtual void SetupSectionPositions( WW8_PdAttrDesc* /*pA*/ ) {}
783 /// Top node of host page when in header/footer.
784 void SetHdFtPageRoot( const SwTextNode *pNd ) { m_pTopNodeOfHdFtPage = pNd; }
786 /// Top node of host page when in header/footer.
787 const SwTextNode *GetHdFtPageRoot() const { return m_pTopNodeOfHdFtPage; }
789 /// Output the actual headers and footers.
790 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
791 const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
792 sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) = 0;
794 /// Write the field
795 virtual void OutputField( const SwField* pField, ww::eField eFieldType,
796 const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) = 0;
798 /// Write the data of the form field
799 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
800 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) = 0;
802 virtual void DoComboBox(const OUString &rName,
803 const OUString &rHelp,
804 const OUString &ToolTip,
805 const OUString &rSelected,
806 const css::uno::Sequence<OUString> &rListItems) = 0;
808 virtual void DoFormText(const SwInputField * pField) = 0;
810 static bool NoPageBreakSection( const SfxItemSet *pSet );
812 // Compute the number format for WW dates
813 bool GetNumberFormat(const SwField& rField, OUString& rStr);
815 virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) = 0;
817 const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const;
818 template<class T> const T* HasItem(TypedWhichId<T> nWhich) const
820 return static_cast<const T*>(HasItem(sal_uInt16(nWhich)));
823 /// Returns the index of a picture bullet, used in numberings.
824 int GetGrfIndex(const SvxBrushItem& rBrush);
826 tools::Long GetParaTabStopOffset() const;
828 enum ExportFormat { DOC = 0, RTF = 1, DOCX = 2};
829 virtual ExportFormat GetExportFormat() const = 0;
831 protected:
832 /// Format-dependent part of the actual export.
833 virtual ErrCode ExportDocument_Impl() = 0;
835 /// Get the next position in the text node to output
836 sal_Int32 GetNextPos( SwWW8AttrIter const * pAttrIter, const SwTextNode& rNode, sal_Int32 nCurrentPos );
838 /// Update the information for GetNextPos().
839 void UpdatePosition( SwWW8AttrIter* pAttrIter, sal_Int32 nCurrentPos );
841 /// Output SwTextNode
842 virtual void OutputTextNode( SwTextNode& );
844 /// Setup the chapter fields (maChapterFieldLocs).
845 void GatherChapterFields();
847 void AddLinkTarget( std::u16string_view rURL );
848 void CollectOutlineBookmarks( const SwDoc &rDoc );
850 bool SetCurrentPageDescFromNode(const SwNode &rNd);
851 bool ContentContainsChapterField(const SwFormatContent &rContent) const;
852 bool FormatHdFtContainsChapterField(const SwFrameFormat &rFormat) const;
854 virtual void SectionBreaksAndFrames( const SwTextNode& rNode ) = 0;
856 virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
857 const SwNode& rNd,
858 const SwFormatPageDesc* pNewPgDescFormat,
859 const SwPageDesc* pNewPgDesc,
860 bool bExtraPageBreak = false ) = 0;
862 /// Return value indicates if an inherited outline numbering is suppressed.
863 virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) = 0;
865 /// Output SwStartNode
866 void OutputStartNode( const SwStartNode& );
868 /// Output SwEndNode
869 virtual void OutputEndNode( const SwEndNode& );
871 /// Output SwGrfNode
872 virtual void OutputGrfNode( const SwGrfNode& ) = 0;
874 /// Output SwOLENode
875 virtual void OutputOLENode( const SwOLENode& ) = 0;
877 virtual void OutputLinkedOLE( const OUString& ) = 0;
879 /// Output SwSectionNode
880 void OutputSectionNode( const SwSectionNode& );
881 static void UpdateTocSectionNodeProperties(const SwSectionNode& rSectionNode);
883 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) = 0;
885 /// Call the right (virtual) function according to the type of the item.
887 /// One of OutputTextNode(), OutputGrfNode(), or OutputOLENode()
888 void OutputContentNode( SwContentNode& );
890 /// Find the nearest bookmark from the current position.
892 /// Returns false when there is no bookmark.
893 bool NearestBookmark( sal_Int32& rNearest, const sal_Int32 nCurrentPos, bool bNextPositionOnly );
895 void GetSortedBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen );
897 bool GetBookmarks( const SwTextNode& rNd, sal_Int32 nStt, sal_Int32 nEnd,
898 IMarkVector& rArr );
900 /// Find the nearest annotation mark from the current position.
902 void NearestAnnotationMark( sal_Int32& rNearest, const sal_Int32 nCurrentPos, bool bNextPositionOnly );
904 void GetSortedAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen );
906 bool GetAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nStt, sal_Int32 nEnd,
907 IMarkVector& rArr );
909 const NfKeywordTable & GetNfKeywordTable();
911 void SetCurPam(SwNodeOffset nStt, SwNodeOffset nEnd);
913 /// Get background color of the document, if there is one.
914 std::unique_ptr<SvxBrushItem> getBackground();
915 /// Populates m_vecBulletPic with all the bullet graphics used by numberings.
916 int CollectGrfsOfBullets();
917 /// Write the numbering picture bullets.
918 void BulletDefinitions();
920 bool NeedSectionBreak( const SwNode& rNd ) const;
921 bool NeedTextNodeSplit( const SwTextNode& rNd, SwSoftPageBreakList& pList ) const;
923 std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets
925 public:
926 MSWordExportBase(SwDoc& rDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam);
927 virtual ~MSWordExportBase();
929 // TODO move as much as possible here from WW8Export! ;-)
931 static void CorrectTabStopInSet( SfxItemSet& rSet, sal_Int32 nAbsLeft );
933 OUString BookmarkToWord(const OUString& rBookmark, bool* pIsMove = nullptr,
934 bool* pIsFrom = nullptr);
936 private:
937 MSWordExportBase( const MSWordExportBase& ) = delete;
938 MSWordExportBase& operator=( const MSWordExportBase& ) = delete;
940 std::unordered_map<OUString, OUString> m_aBookmarkToWord;
941 o3tl::sorted_vector<OUString> m_aWordBookmarks;
944 /// The writer class that gets called for the WW8 filter.
945 class SwWW8Writer: public StgWriter
947 // friends to get access to m_pExport
948 // FIXME avoid that, this is probably not what we want
949 // (if yes, remove the friends, and provide here a GetExport() method)
950 friend void WW8_WrtRedlineAuthor::Write(Writer &rWrt);
952 WW8Export *m_pExport;
953 SfxMedium *mpMedium;
955 public:
956 SwWW8Writer(std::u16string_view rFltName, const OUString& rBaseURL);
957 virtual ~SwWW8Writer() override;
959 virtual ErrCode WriteStorage() override;
960 virtual ErrCode WriteMedium( SfxMedium& ) override;
962 // TODO most probably we want to be able to get these in
963 // MSExportFilterBase
964 using Writer::getIDocumentSettingAccess;
966 public:
967 static void InsUInt16(ww::bytes &rO, sal_uInt16 n);
968 static void InsUInt32(ww::bytes &rO, sal_uInt32 n);
969 static void InsAsString16(ww::bytes &rO, const OUString& rStr);
970 static void InsAsString8(ww::bytes & O, std::u16string_view rStr,
971 rtl_TextEncoding eCodeSet);
973 static sal_uLong FillUntil( SvStream& rStrm, sal_uLong nEndPos = 0 );
974 static void FillCount( SvStream& rStrm, sal_uLong nCount );
976 static void WriteShort( SvStream& rStrm, sal_Int16 nVal ) { rStrm.WriteInt16( nVal ); }
977 static void WriteShort( SvStream& rStrm, sal_uLong nPos, sal_Int16 nVal );
979 static void WriteLong( SvStream& rStrm, sal_Int32 nVal ) { rStrm.WriteInt32( nVal ); }
980 static void WriteLong( SvStream& rStrm, sal_uLong nPos, sal_Int32 nVal );
982 static void WriteString16(SvStream& rStrm, const OUString& rStr,
983 bool bAddZero);
984 static void WriteString8(SvStream& rStrm, std::u16string_view rStr,
985 bool bAddZero, rtl_TextEncoding eCodeSet);
987 static void WriteString_xstz(SvStream& rStrm, const OUString& rStr, bool bAddZero);
989 bool InitStd97CodecUpdateMedium( ::msfilter::MSCodec_Std97& rCodec );
991 using StgWriter::Write;
992 virtual ErrCode Write( SwPaM&, SfxMedium&, const OUString* ) override;
993 //Seems not an expected to provide method to access the private member
994 SfxMedium* GetMedia() { return mpMedium; }
996 private:
997 SwWW8Writer(const SwWW8Writer&) = delete;
998 SwWW8Writer& operator=(const SwWW8Writer&) = delete;
999 ErrCode WriteStorageImpl();
1002 /// Exporter of the binary Word file formats.
1003 class WW8Export : public MSWordExportBase
1005 public:
1006 std::unique_ptr<ww::bytes> m_pO; ///< Buffer
1008 SvStream *m_pTableStrm, *m_pDataStrm; ///< Streams for WW97 Export
1010 std::unique_ptr<WW8Fib> m_pFib; ///< File Information Block
1011 std::unique_ptr<WW8Dop> m_pDop; ///< Document Properties
1012 std::unique_ptr<WW8_WrPlcFootnoteEdn> m_pFootnote; ///< Footnotes - structure to remember them, and output
1013 std::unique_ptr<WW8_WrPlcFootnoteEdn> m_pEdn; ///< Endnotes - structure to remember them, and output
1014 std::unique_ptr<WW8_WrPlcSepx> m_pSepx; ///< Sections/headers/footers
1016 bool m_bDot; ///< Template or document.
1018 protected:
1019 SwWW8Writer *m_pWriter; ///< Pointer to the writer
1020 std::unique_ptr<WW8AttributeOutput> m_pAttrOutput; ///< Converting attributes to stream data
1022 private:
1023 tools::SvRef<SotStorage> m_xEscherStg; /// memory leak #i120098#, to hold the reference to unnamed SotStorage obj
1025 public:
1026 /// Access to the attribute output class.
1027 virtual AttributeOutputBase& AttrOutput() const override;
1029 /// Access to the sections/headers/footres.
1030 virtual MSWordSections& Sections() const override;
1032 virtual bool PreferPageBreakBefore() const override { return true; }
1034 virtual bool FieldsQuoted() const override { return false; }
1036 virtual bool AddSectionBreaksForTOX() const override { return false; }
1037 private:
1038 /// Format-dependent part of the actual export.
1039 virtual ErrCode ExportDocument_Impl() override;
1041 void PrepareStorage();
1042 void WriteFkpPlcUsw();
1043 void WriteMainText();
1044 void StoreDoc1();
1046 /// Output the numbering table.
1047 virtual void WriteNumbering() override;
1049 void OutOverrideListTab();
1050 void OutListNamesTab();
1052 void RestoreMacroCmds();
1054 void DoComboBox(css::uno::Reference<css::beans::XPropertySet> const & xPropSet);
1056 public:
1058 /// Setup the pA's info.
1059 virtual void SetupSectionPositions( WW8_PdAttrDesc* pA ) override;
1061 bool MiserableFormFieldExportHack(const SwFrameFormat& rFrameFormat);
1063 SwMSConvertControls& GetOCXExp() { return *m_pOCXExp; }
1064 void ExportDopTypography(WW8DopTypography &rTypo);
1066 sal_uInt16 AddRedlineAuthor( std::size_t nId );
1068 void WriteFootnoteBegin( const SwFormatFootnote& rFootnote, ww::bytes* pO = nullptr );
1069 void WritePostItBegin( ww::bytes* pO = nullptr );
1070 const SvxBrushItem* GetCurrentPageBgBrush() const;
1071 std::shared_ptr<SvxBrushItem> TrueFrameBgBrush(const SwFrameFormat &rFlyFormat) const;
1073 void AppendFlyInFlys(const ww8::Frame& rFrameFormat, const Point& rNdTopLeft);
1074 void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
1075 void WriteSdrTextObj(const SdrTextObj& rObj, sal_uInt8 nTyp);
1077 sal_uInt32 GetSdrOrdNum( const SwFrameFormat& rFormat ) const;
1078 void CreateEscher();
1079 void WriteEscher();
1081 /// Write the field
1082 virtual void OutputField( const SwField* pField, ww::eField eFieldType,
1083 const OUString& rFieldCmd, FieldFlags nMode = FieldFlags::All ) override;
1085 void StartCommentOutput( std::u16string_view rName );
1086 void EndCommentOutput( std::u16string_view rName );
1087 void OutGrf(const ww8::Frame &rFrame);
1088 bool TestOleNeedsGraphic(const SwAttrSet& rSet, tools::SvRef<SotStorage> const& xOleStg,
1089 const tools::SvRef<SotStorage>& xObjStg, OUString const& rStorageName,
1090 SwOLENode* pOLENd);
1092 virtual void AppendBookmarks( const SwTextNode& rNd, sal_Int32 nCurrentPos, sal_Int32 nLen, const SwRedlineData* pRedlineData = nullptr ) override;
1093 virtual void AppendBookmark( const OUString& rName ) override;
1094 void AppendBookmarkEndWithCorrection( const OUString& rName );
1096 virtual void AppendAnnotationMarks( const SwWW8AttrIter& rAttrs, sal_Int32 nCurrentPos, sal_Int32 nLen ) override;
1098 virtual void AppendSmartTags(SwTextNode& rTextNode) override;
1100 virtual void ExportGrfBullet(const SwTextNode& rNd) override;
1101 void OutGrfBullets(const ww8::Frame &rFrame);
1103 void MoveFieldMarks(WW8_CP nFrom, WW8_CP nTo);
1105 void WriteAsStringTable(const std::vector<OUString>&, sal_Int32& rfcSttbf,
1106 sal_Int32& rlcbSttbf);
1108 virtual sal_uInt64 ReplaceCr( sal_uInt8 nChar ) override;
1110 virtual void WriteCR( ww8::WW8TableNodeInfoInner::Pointer_t pTableTextNodeInfoInner = ww8::WW8TableNodeInfoInner::Pointer_t() ) override;
1111 void WriteChar( sal_Unicode c ) override;
1113 void OutSwString(const OUString&, sal_Int32 nStt, sal_Int32 nLen);
1115 WW8_CP Fc2Cp( sal_uLong nFc ) const { return m_pPiece->Fc2Cp( nFc ); }
1117 // some partly static semi-internal function declarations
1119 void OutSprmBytes( sal_uInt8* pBytes, sal_uInt16 nSiz )
1120 { m_pO->insert( m_pO->end(), pBytes, pBytes+nSiz ); }
1122 virtual void SectionBreaksAndFrames( const SwTextNode& rNode ) override;
1124 /// Helper method for OutputSectionBreaks() and OutputFollowPageDesc().
1125 // #i76300#
1126 virtual void PrepareNewPageDesc( const SfxItemSet* pSet,
1127 const SwNode& rNd,
1128 const SwFormatPageDesc* pNewPgDescFormat,
1129 const SwPageDesc* pNewPgDesc,
1130 bool bExtraPageBreak = false ) override;
1132 static void Out_BorderLine(ww::bytes& rO, const ::editeng::SvxBorderLine* pLine,
1133 sal_uInt16 nDist, sal_uInt16 nSprmNo, sal_uInt16 nSprmNoVer9,
1134 bool bShadow);
1136 void Out_SwFormatBox(const SvxBoxItem& rBox, bool bShadow);
1137 static void Out_SwFormatTableBox( ww::bytes& rO, const SvxBoxItem * rBox );
1138 void Out_CellRangeBorders(const SvxBoxItem * pBox, sal_uInt8 nStart,
1139 sal_uInt8 nLimit);
1140 static bool TransBrush(const Color& rCol, WW8_SHD& rShd);
1141 static WW8_BRCVer9 TranslateBorderLine(const ::editeng::SvxBorderLine& pLine,
1142 sal_uInt16 nDist, bool bShadow);
1144 // #i77805# - new return value indicates, if an inherited outline numbering is suppressed
1145 virtual bool DisallowInheritingOutlineNumbering(const SwFormat &rFormat) override;
1147 unsigned int GetHdFtIndex() const { return m_nHdFtIndex; }
1148 void SetHdFtIndex(unsigned int nHdFtIndex) { m_nHdFtIndex = nHdFtIndex; }
1149 void IncrementHdFtIndex() { ++m_nHdFtIndex; }
1152 * Converts the SVX numbering type to MSONFC.
1154 * This is used for section, footnote and endnote numbering purposes.
1156 static sal_uInt8 GetNumId( sal_uInt16 eNumType );
1158 /// Guess the script (asian/western).
1159 virtual bool CollapseScriptsforWordOk( sal_uInt16 nScript, sal_uInt16 nWhich ) override;
1161 SwTwips CurrentPageWidth(SwTwips &rLeft, SwTwips &rRight) const;
1163 /// Nasty swap for bidi if necessary
1164 void MiserableRTLFrameFormatHack(SwTwips &rLeft, SwTwips &rRight,
1165 const ww8::Frame &rFrameFormat);
1167 void InsUInt16( sal_uInt16 n ) { SwWW8Writer::InsUInt16( *m_pO, n ); }
1168 void InsInt16(sal_Int16 n) { InsUInt16(sal_uInt16(n)); }
1169 void InsUInt32( sal_uInt32 n ) { SwWW8Writer::InsUInt32( *m_pO, n ); }
1170 void WriteStringAsPara( const OUString& rText );
1172 /// Setup the exporter.
1173 WW8Export( SwWW8Writer *pWriter,
1174 SwDoc& rDocument, std::shared_ptr<SwUnoCursor> & pCurrentPam, SwPaM* pOriginalPam,
1175 bool bDot );
1176 virtual ~WW8Export() override;
1178 virtual void DoComboBox(const OUString &rName,
1179 const OUString &rHelp,
1180 const OUString &ToolTip,
1181 const OUString &rSelected,
1182 const css::uno::Sequence<OUString> &rListItems) override;
1184 virtual void DoFormText(const SwInputField * pField) override;
1186 void GetCurrentItems(ww::bytes &rItems) const;
1188 /// Write the data of the form field
1189 virtual void WriteFormData( const ::sw::mark::IFieldmark& rFieldmark ) override;
1190 virtual void WriteHyperlinkData( const ::sw::mark::IFieldmark& rFieldmark ) override;
1192 /// Fields.
1193 WW8_WrPlcField* CurrentFieldPlc() const;
1195 SwWW8Writer& GetWriter() const { return *m_pWriter; }
1196 SvStream& Strm() const { return m_pWriter->Strm(); }
1198 /// Remember some of the members so that we can recurse in WriteText().
1199 virtual void SaveData( SwNodeOffset nStt, SwNodeOffset nEnd ) override;
1201 /// Restore what was saved in SaveData().
1202 virtual void RestoreData() override;
1204 /// Output the actual headers and footers.
1205 virtual void WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
1206 const SwFrameFormat& rFormat, const SwFrameFormat& rLeftHeaderFormat, const SwFrameFormat& rLeftFooterFormat, const SwFrameFormat& rFirstPageFormat,
1207 sal_uInt8 nBreakCode, bool bEvenAndOddHeaders) override;
1209 virtual ExportFormat GetExportFormat() const override { return ExportFormat::DOC; }
1211 protected:
1212 /// Output SwGrfNode
1213 virtual void OutputGrfNode( const SwGrfNode& ) override;
1215 /// Output SwOLENode
1216 virtual void OutputOLENode( const SwOLENode& ) override;
1218 virtual void OutputLinkedOLE( const OUString& ) override;
1220 virtual void AppendSection( const SwPageDesc *pPageDesc, const SwSectionFormat* pFormat, sal_uLong nLnNum ) override;
1222 private:
1223 WW8Export(const WW8Export&) = delete;
1224 WW8Export& operator=(const WW8Export&) = delete;
1227 class WW8_WrPlcSubDoc // double Plc for Footnotes/Endnotes and Postits
1229 private:
1230 WW8_WrPlcSubDoc(const WW8_WrPlcSubDoc&) = delete;
1231 WW8_WrPlcSubDoc& operator=(const WW8_WrPlcSubDoc&) = delete;
1232 protected:
1233 std::vector<WW8_CP> m_aCps;
1234 std::vector<const void*> m_aContent; // PTRARR of SwFormatFootnote/PostIts/..
1235 std::vector<const SwFrameFormat*> m_aSpareFormats; // a backup for aContent: if there's no SdrObject, stores the fmt directly here
1236 std::unique_ptr<WW8_WrPlc0> m_pTextPos; // positions of the individual texts
1238 WW8_WrPlcSubDoc();
1239 virtual ~WW8_WrPlcSubDoc();
1241 bool WriteGenericText( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_CP& rCount );
1242 void WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, WW8_FC& rTextStt,
1243 sal_Int32& rTextCnt, WW8_FC& rRefStt, sal_Int32& rRefCnt ) const;
1245 virtual const std::vector<sal_uInt32>* GetShapeIdArr() const;
1248 // double Plc for Footnotes/Endnotes
1249 class WW8_WrPlcFootnoteEdn : public WW8_WrPlcSubDoc
1251 private:
1252 sal_uInt8 m_nTyp;
1254 WW8_WrPlcFootnoteEdn(const WW8_WrPlcFootnoteEdn&) = delete;
1255 WW8_WrPlcFootnoteEdn& operator=(WW8_WrPlcFootnoteEdn const &) = delete;
1256 public:
1257 explicit WW8_WrPlcFootnoteEdn( sal_uInt8 nTTyp ) : m_nTyp( nTTyp ) {}
1259 bool WriteText( WW8Export& rWrt );
1260 void WritePlc( WW8Export& rWrt ) const;
1262 void Append( WW8_CP nCp, const SwFormatFootnote& rFootnote );
1265 struct WW8_Annotation
1267 const OutlinerParaObject* mpRichText;
1268 OUString msSimpleText;
1269 OUString msOwner;
1270 OUString m_sInitials;
1271 DateTime maDateTime;
1272 WW8_CP m_nRangeStart, m_nRangeEnd;
1273 bool m_bIgnoreEmpty = true;
1274 WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd);
1275 explicit WW8_Annotation(const SwRedlineData* pRedline);
1276 /// An annotation has a range if start != end or the m_bIgnoreEmpty flag is cleared.
1277 bool HasRange() const;
1280 class WW8_WrPlcAnnotations : public WW8_WrPlcSubDoc // double Plc for Postits
1282 private:
1283 WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&) = delete;
1284 WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations const &) = delete;
1285 o3tl::sorted_vector<const SwRedlineData*> maProcessedRedlines;
1287 std::map<const OUString, std::pair<WW8_CP, bool>> m_aRangeStartPositions;
1288 public:
1289 WW8_WrPlcAnnotations() {}
1290 virtual ~WW8_WrPlcAnnotations() override;
1292 void AddRangeStartPosition(const OUString& rName, WW8_CP nStartCp, bool bIgnoreEmpty);
1293 void Append( WW8_CP nCp, const SwPostItField* pPostIt );
1294 void Append( WW8_CP nCp, const SwRedlineData* pRedLine );
1295 bool IsNewRedlineComment( const SwRedlineData* pRedLine );
1296 bool WriteText( WW8Export& rWrt );
1297 void WritePlc( WW8Export& rWrt ) const;
1300 class WW8_WrPlcTextBoxes : public WW8_WrPlcSubDoc // double Plc for Textboxes
1301 { // Frame/DrawTextboxes!
1302 private:
1303 sal_uInt8 m_nTyp;
1304 std::vector<sal_uInt32> m_aShapeIds; // VARARR of ShapeIds for the SwFrameFormats
1305 virtual const std::vector<sal_uInt32>* GetShapeIdArr() const override;
1307 WW8_WrPlcTextBoxes(const WW8_WrPlcTextBoxes&) = delete;
1308 WW8_WrPlcTextBoxes& operator=(WW8_WrPlcTextBoxes const &) = delete;
1309 public:
1310 explicit WW8_WrPlcTextBoxes( sal_uInt8 nTTyp ) : m_nTyp( nTTyp ) {}
1312 bool WriteText( WW8Export& rWrt );
1313 void WritePlc( WW8Export& rWrt ) const;
1314 void Append( const SdrObject& rObj, sal_uInt32 nShapeId );
1315 void Append( const SwFrameFormat* pFormat, sal_uInt32 nShapeId );
1316 sal_uInt16 Count() const { return m_aContent.size(); }
1317 sal_uInt16 GetPos( const void* p ) const
1319 std::vector<const void*>::const_iterator it
1320 = std::find( m_aContent.begin(), m_aContent.end(), p );
1321 return it == m_aContent.end() ? USHRT_MAX : it - m_aContent.begin();
1325 class WW8_WrPlcPn // Plc for Page Numbers
1327 private:
1328 WW8Export& m_rWrt;
1329 // Plc for Chpx and Papx ( incl PN-Plc )
1330 std::vector<std::unique_ptr<WW8_WrFkp>> m_Fkps;
1331 sal_uInt16 m_nFkpStartPage;
1332 ePLCFT m_ePlc;
1334 WW8_WrPlcPn(const WW8_WrPlcPn&) = delete;
1335 WW8_WrPlcPn& operator=(const WW8_WrPlcPn&) = delete;
1336 public:
1337 WW8_WrPlcPn( WW8Export& rWrt, ePLCFT ePl, WW8_FC nStartFc );
1338 ~WW8_WrPlcPn();
1339 void AppendFkpEntry(WW8_FC nEndFc,short nVarLen = 0,const sal_uInt8* pSprms = nullptr);
1340 void WriteFkps();
1341 void WritePlc();
1342 sal_uInt8 *CopyLastSprms(sal_uInt8 &rLen);
1345 // class WW8_WrPlc1 is only used for fields
1346 class WW8_WrPlc1
1348 private:
1349 std::vector<WW8_CP> m_aPos;
1350 std::unique_ptr<sal_uInt8[]> m_pData; // content ( structures )
1351 sal_uLong m_nDataLen;
1352 sal_uInt16 m_nStructSiz;
1354 WW8_WrPlc1(const WW8_WrPlc1&) = delete;
1355 WW8_WrPlc1& operator=(const WW8_WrPlc1&) = delete;
1356 protected:
1357 sal_uInt16 Count() const { return m_aPos.size(); }
1358 void Write( SvStream& rStrm );
1359 WW8_CP Prev() const;
1360 public:
1361 explicit WW8_WrPlc1( sal_uInt16 nStructSz );
1362 ~WW8_WrPlc1();
1363 void Append( WW8_CP nCp, const void* pData );
1364 void Finish( sal_uLong nLastCp, sal_uLong nStartCp );
1367 // class WW8_WrPlcField is for fields
1368 class WW8_WrPlcField : public WW8_WrPlc1
1370 private:
1371 sal_uInt8 m_nTextTyp;
1372 sal_uInt16 m_nResults;
1374 WW8_WrPlcField(const WW8_WrPlcField&) = delete;
1375 WW8_WrPlcField& operator=(const WW8_WrPlcField&) = delete;
1376 public:
1377 WW8_WrPlcField( sal_uInt16 nStructSz, sal_uInt8 nTTyp )
1378 : WW8_WrPlc1( nStructSz ), m_nTextTyp( nTTyp ), m_nResults(0)
1380 void Write( WW8Export& rWrt );
1381 void ResultAdded() { ++m_nResults; }
1382 sal_uInt16 ResultCount() const { return m_nResults; }
1385 class WW8_WrMagicTable : public WW8_WrPlc1
1387 private:
1388 WW8_WrMagicTable(const WW8_WrMagicTable&) = delete;
1389 WW8_WrMagicTable& operator=(const WW8_WrMagicTable&) = delete;
1390 public:
1391 WW8_WrMagicTable() : WW8_WrPlc1( 4 ) {Append(0,0);}
1392 void Append( WW8_CP nCp, sal_uLong nData );
1393 void Write( WW8Export& rWrt );
1396 class GraphicDetails
1398 public:
1399 ww8::Frame maFly; // surrounding FlyFrames
1400 sal_uLong mnPos; // FilePos of the graphics
1401 sal_uInt16 mnWid; // Width of the graphics
1402 sal_uInt16 mnHei; // Height of the graphics
1404 GraphicDetails(const ww8::Frame &rFly, sal_uInt16 nWid, sal_uInt16 nHei)
1405 : maFly(rFly), mnPos(0), mnWid(nWid), mnHei(nHei)
1408 bool operator==(const GraphicDetails& rIn) const
1410 return (
1411 (mnWid == rIn.mnWid) && (mnHei == rIn.mnHei) &&
1412 (maFly.RefersToSameFrameAs(rIn.maFly))
1417 // class SwWW8WrGrf collects graphics and issues them
1418 class SwWW8WrGrf
1420 private:
1421 /// for access to the variables
1422 WW8Export& m_rWrt;
1424 std::vector<GraphicDetails> maDetails;
1425 sal_uInt16 mnIdx; // index in file positions
1427 static void WritePICFHeader(SvStream& rStrm, const ww8::Frame &rFly,
1428 sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight,
1429 const SwAttrSet* pAttrSet = nullptr);
1430 void WriteGraphicNode(SvStream& rStrm, const GraphicDetails &rItem);
1431 void WriteGrfFromGrfNode(SvStream& rStrm, const SwGrfNode &rNd,
1432 const ww8::Frame &rFly, sal_uInt16 nWidth, sal_uInt16 nHeight);
1434 static void WritePICBulletFHeader(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 mm, sal_uInt16 nWidth, sal_uInt16 nHeight);
1435 void WriteGrfForBullet(SvStream& rStrm, const Graphic &rGrf, sal_uInt16 nWidth, sal_uInt16 nHeight);
1437 SwWW8WrGrf(const SwWW8WrGrf&) = delete;
1438 SwWW8WrGrf& operator=(const SwWW8WrGrf&) = delete;
1439 public:
1440 explicit SwWW8WrGrf( WW8Export& rW ) : m_rWrt( rW ), mnIdx( 0 ) {}
1441 void Insert(const ww8::Frame &rFly);
1442 void Write();
1443 sal_uLong GetFPos()
1444 { return (mnIdx < maDetails.size()) ? maDetails[mnIdx++].mnPos : 0; }
1447 /** The class MSWordAttrIter is a helper class to build the Fkp.chpx.
1448 This is a base class to output the SwTextAttrs and the EditEngineTextAttrs.
1450 class MSWordAttrIter
1452 private:
1453 MSWordAttrIter* m_pOld;
1454 MSWordAttrIter(const MSWordAttrIter&) = delete;
1455 MSWordAttrIter& operator=(const MSWordAttrIter&) = delete;
1456 protected:
1457 MSWordExportBase& m_rExport;
1458 public:
1459 explicit MSWordAttrIter( MSWordExportBase& rExport );
1460 virtual ~MSWordAttrIter();
1462 virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const = 0;
1463 template<class T> const T* HasTextItem( TypedWhichId<T> nWhich ) const
1465 return static_cast<const T*>(HasTextItem(sal_uInt16(nWhich)));
1467 virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const = 0;
1470 /// Used to export formatted text associated to drawings.
1471 class MSWord_SdrAttrIter : public MSWordAttrIter
1473 private:
1474 const EditTextObject* m_pEditObj;
1475 const SfxItemPool* m_pEditPool;
1476 std::vector<EECharAttrib> m_aTextAtrArr;
1477 std::vector<const EECharAttrib*> m_aChrTextAtrArr;
1478 std::vector<rtl_TextEncoding> m_aChrSetArr;
1479 sal_Int32 m_nPara;
1480 sal_Int32 m_nCurrentSwPos;
1481 sal_Int32 m_nTmpSwPos; // for HasItem()
1482 rtl_TextEncoding m_eNdChrSet;
1483 sal_uInt16 m_nScript;
1484 sal_uInt8 mnTyp;
1486 sal_Int32 SearchNext( sal_Int32 nStartPos );
1487 void SetCharSet(const EECharAttrib& rTextAttr, bool bStart);
1489 void SetItemsThatDifferFromStandard(bool bCharAttr, SfxItemSet& rSet);
1491 MSWord_SdrAttrIter(const MSWord_SdrAttrIter&) = delete;
1492 MSWord_SdrAttrIter& operator=(const MSWord_SdrAttrIter&) = delete;
1493 public:
1494 MSWord_SdrAttrIter( MSWordExportBase& rWr, const EditTextObject& rEditObj,
1495 sal_uInt8 nType );
1496 void NextPara( sal_Int32 nPar );
1497 void OutParaAttr(bool bCharAttr, const std::set<sal_uInt16>* pWhichsToIgnore = nullptr);
1498 void OutEEField(const SfxPoolItem& rHt);
1500 bool IsTextAttr(sal_Int32 nSwPos);
1502 void NextPos() { if ( m_nCurrentSwPos < SAL_MAX_INT32 ) m_nCurrentSwPos = SearchNext( m_nCurrentSwPos + 1 ); }
1504 void OutAttr( sal_Int32 nSwPos );
1505 virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
1506 virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
1507 sal_Int32 WhereNext() const { return m_nCurrentSwPos; }
1508 rtl_TextEncoding GetNextCharSet() const;
1509 rtl_TextEncoding GetNodeCharSet() const { return m_eNdChrSet; }
1512 // class SwWW8AttrIter is a helper for constructing the Fkp.chpx.
1513 // Only character attributes are considered; paragraph attributes do not need this treatment.
1514 // The paragraph and text attributes of the Writer are passed, and
1515 // Where() returns the next position where the attributes change.
1516 // IsTextAtr() tells if, at the position returned by Where(), there is
1517 // an attribute without end and with \xff in the text.
1518 // Using OutAttr(), the attributes on the passed SwPos are returned.
1519 class SwWW8AttrIter : public MSWordAttrIter
1521 private:
1522 const SwTextNode& m_rNode;
1524 sw::util::CharRuns maCharRuns;
1525 sw::util::CharRuns::const_iterator maCharRunIter;
1527 rtl_TextEncoding meChrSet;
1528 sal_uInt16 mnScript;
1529 bool mbCharIsRTL;
1531 const SwRangeRedline* m_pCurRedline;
1532 sal_Int32 m_nCurrentSwPos;
1533 SwRedlineTable::size_type m_nCurRedlinePos;
1535 bool mbParaIsRTL;
1537 const SwFormatDrop &mrSwFormatDrop;
1539 ww8::Frames maFlyFrames; // #i2916#
1540 ww8::FrameIter maFlyIter;
1542 sal_Int32 SearchNext( sal_Int32 nStartPos );
1544 void OutSwFormatRefMark(const SwFormatRefMark& rAttr);
1546 void IterToCurrent();
1548 SwWW8AttrIter(const SwWW8AttrIter&) = delete;
1549 SwWW8AttrIter& operator=(const SwWW8AttrIter&) = delete;
1551 void handleToggleProperty(SfxItemSet& rExportSet, const SwFormatCharFormat* pCharFormatItem, sal_uInt16 nWhich, const SfxPoolItem* pValue);
1552 public:
1553 SwWW8AttrIter( MSWordExportBase& rWr, const SwTextNode& rNd );
1555 bool IsTextAttr( sal_Int32 nSwPos ) const;
1556 bool IsExportableAttr(sal_Int32 nSwPos) const;
1557 bool IncludeEndOfParaCRInRedlineProperties(sal_Int32 nPos) const;
1558 bool IsDropCap( int nSwPos );
1559 bool RequiresImplicitBookmark();
1561 void NextPos() { if ( m_nCurrentSwPos < SAL_MAX_INT32 ) m_nCurrentSwPos = SearchNext( m_nCurrentSwPos + 1 ); }
1563 void OutAttr(sal_Int32 nSwPos, bool bWriteCombinedChars);
1564 virtual const SfxPoolItem* HasTextItem( sal_uInt16 nWhich ) const override;
1565 virtual const SfxPoolItem& GetItem( sal_uInt16 nWhich ) const override;
1566 int OutAttrWithRange(const SwTextNode& rNode, sal_Int32 nPos);
1567 const SwRedlineData* GetParagraphLevelRedline( );
1568 const SwRedlineData* GetRunLevelRedline( sal_Int32 nPos );
1569 FlyProcessingState OutFlys(sal_Int32 nSwPos);
1570 bool HasFlysAt(sal_Int32 nSwPos) const;
1572 sal_Int32 WhereNext() const { return m_nCurrentSwPos; }
1573 sal_uInt16 GetScript() const { return mnScript; }
1574 bool IsParaRTL() const { return mbParaIsRTL; }
1575 rtl_TextEncoding GetCharSet() const { return meChrSet; }
1576 OUString GetSnippet(const OUString &rStr, sal_Int32 nCurrentPos,
1577 sal_Int32 nLen) const;
1578 const SwFormatDrop& GetSwFormatDrop() const { return mrSwFormatDrop; }
1580 bool IsWatermarkFrame();
1581 bool IsAnchorLinkedToThisNode( SwNodeOffset nNodePos );
1583 void SplitRun( sal_Int32 nSplitEndPos );
1585 const SwTextNode& GetNode() const { return m_rNode; }
1588 /// Class to collect and output the styles table.
1589 class MSWordStyles
1591 MSWordExportBase& m_rExport;
1592 sal_uInt16 m_aHeadingParagraphStyles[MAXLEVEL];
1594 struct MapEntry
1596 const SwFormat* format = nullptr;
1597 const SwNumRule* num_rule = nullptr;
1598 /// We need to build style id's for DOCX export; ideally we should roundtrip that, but this is good enough.
1599 sal_uInt16 ww_id = ww::stiUser;
1600 OUString ww_name;
1601 OString style_id;
1603 MapEntry() = default;
1604 MapEntry(const SwFormat* f) : format(f) { if (f) ww_id = GetWWId(*f); }
1605 MapEntry(const SwNumRule* r) : num_rule(r) {}
1607 std::vector<MapEntry> m_aStyles; ///< Slot <-> Character/paragraph/list style array.
1608 bool m_bListStyles; ///< If list styles are requested to be exported as well.
1610 /// Create the style table, called from the constructor.
1611 void BuildStylesTable();
1613 /// Generate proper Word names, taking mapping between special types into account
1614 void BuildWwNames();
1616 /// Based on style names, fill in unique, MS-like names.
1617 void BuildStyleIds();
1619 /// Return information about one style.
1620 void GetStyleData( const SwFormat* pFormat, bool& bFormatColl, sal_uInt16& nBase, sal_uInt16& nNext, sal_uInt16& nLink );
1622 /// Outputs attributes of one style.
1623 void WriteProperties( const SwFormat* pFormat, bool bPap, sal_uInt16 nPos, bool bInsDefCharSiz );
1625 static sal_uInt16 GetWWId( const SwFormat& rFormat );
1627 void SetStyleDefaults( const SwFormat& rFormat, bool bPap );
1629 /// Outputs one style - called (in a loop) from OutputStylesTable().
1630 void OutputStyle( sal_uInt16 nSlot );
1632 MSWordStyles( const MSWordStyles& ) = delete;
1633 MSWordStyles& operator=( const MSWordStyles& ) = delete;
1635 public:
1636 MSWordStyles( MSWordExportBase& rExport, bool bListStyles = false );
1637 ~MSWordStyles();
1639 /// Output the styles table.
1640 void OutputStylesTable();
1642 /// Get slot of the style (rFormat).
1643 sal_uInt16 GetSlot( const SwFormat* pFormat ) const;
1645 /// create style id using only ASCII characters of the style name
1646 static OString CreateStyleId(std::u16string_view aName);
1648 /// Get styleId of the nSlot-th style (nSlot is its position in m_aStyles).
1649 OString const & GetStyleId(sal_uInt16 nSlot) const;
1650 /// the awful TOC field references names, not styleIds
1651 OUString GetStyleWWName(SwFormat const* pFormat) const;
1653 const SwFormat* GetSwFormat(sal_uInt16 nSlot) const { return m_aStyles[nSlot].format; }
1654 /// Get numbering rule of the nSlot-th style
1655 const SwNumRule* GetSwNumRule(sal_uInt16 nSlot) const { return m_aStyles[nSlot].num_rule; }
1656 sal_uInt16 GetHeadingParagraphStyleId(sal_uInt16 nLevel) const { return m_aHeadingParagraphStyles[ nLevel ]; }
1659 #define MSWORD_MAX_STYLES_LIMIT 4091
1661 sal_Int16 GetWordFirstLineOffset(const SwNumFormat &rFormat);
1662 // A bit of a bag on the side for now
1663 OUString FieldString(ww::eField eIndex);
1665 class WW8SHDLong
1667 sal_uInt32 m_cvFore;
1668 sal_uInt32 m_cvBack;
1670 public:
1671 WW8SHDLong() : m_cvFore(0), m_cvBack(0) {}
1673 void Write(WW8Export & rExport);
1674 void setCvFore(sal_uInt32 cvFore) { m_cvFore = cvFore; }
1675 void setCvBack(sal_uInt32 cvBack) { m_cvBack = cvBack; }
1678 #endif // INCLUDED_SW_SOURCE_FILTER_WW8_WRTWW8_HXX
1680 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */