crashtesting: assert on reimport of docx export of ooo102874-2.doc
[LibreOffice.git] / sw / source / filter / ww8 / ww8par.hxx
blob9512550fe93c379485460477840e9653f18863b0
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_WW8PAR_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR_HXX
23 #include <rtl/ustring.hxx>
24 #include <filter/msfilter/msdffimp.hxx>
25 #include <filter/msfilter/util.hxx>
26 #include <editeng/frmdir.hxx>
27 #include <svl/zforlist.hxx>
28 #include <fltshell.hxx>
30 #include <svx/svdobj.hxx>
32 #include <utility>
33 #include <vector>
34 #include <stack>
35 #include <string_view>
36 #include <deque>
37 #include <map>
38 #include <memory>
39 #include <optional>
41 #include "ww8struc.hxx"
42 #include "ww8scan.hxx"
43 #include "ww8glsy.hxx"
44 #include "ww8graf.hxx"
45 #include "wrtww8.hxx"
46 #include <msfilter.hxx>
47 #include <xmloff/odffields.hxx>
48 #include <IMark.hxx>
50 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
51 #include <swtypes.hxx>
52 #include <fmtfsize.hxx>
53 #include <fmtornt.hxx>
54 #include <fmtsrnd.hxx>
55 #include <ndtxt.hxx>
56 #include <editeng/lrspitem.hxx>
57 #include <o3tl/sorted_vector.hxx>
58 #include <oox/ole/olehelper.hxx>
60 #define SW_UD_IMAPDATA 2
62 class SwDoc;
63 class SwPaM;
64 class SfxPoolItem;
65 class SwTextFormatColl;
66 class SwPageDesc;
67 class SvxBoxItem;
68 class SwFormat;
69 class SwNodeIndex;
70 class SwFlyFrameFormat;
71 class SwAttrSet;
72 class SwNumRule;
73 class SwFrameFormat;
74 class Writer;
75 class SwFormatField;
76 class WW8Fib;
77 class WW8PLCFMan;
78 struct WW8PLCFManResult;
79 class WW8RStyle;
80 class WW8PLCF_HdFt;
81 class WW8ScannerBase;
82 struct WW8FlyPara;
83 struct WW8SwFlyPara;
84 struct WW8_PIC;
85 class WW8TabDesc;
86 struct WW8_SHD;
87 struct WW8_OLST;
88 class SwNumFormat;
89 struct WW8_ANLD;
90 struct WW8_ANLV;
91 struct WW8_DO;
92 struct WW8_DPHEAD;
93 struct WW8_FSPA;
94 class SdrModel;
95 class SdrPage;
96 class SdrObject;
97 class SdrTextObj;
98 class SdrUnoObj;
99 class Size;
100 class EditEngine;
101 struct SwPosition;
102 class WW8ReaderSave;
103 struct WW8PicDesc;
104 class Graphic;
105 class SwFieldType;
106 class SotStorage;
107 class SwAttrSet;
108 class GDIMetaFile;
109 struct ESelection;
110 class SfxItemSet;
111 class OutlinerParaObject;
112 enum class SwLineBreakClear;
114 namespace com::sun::star{
115 namespace beans{ class XPropertySet;}
116 namespace form { class XFormComponent;}
117 namespace drawing{class XShape;}
118 namespace lang{class XMultiServiceFactory;}
121 // defines only for the WW8-variable of the INI file
122 #define WW8FL_NO_STYLES 2
123 #define WW8FL_NO_GRAF 0x80
125 #define WW8FL_NO_OUTLINE 0x1000
126 #define WW8FL_NO_IMPLPASP 0x4000 // no implicit para space
127 #define WW8FL_NO_GRAFLAYER 0x8000
129 // Add-on-filter-flags, valid from Winword 8 on
130 #define WW8FL_NO_FLY_FOR_TXBX 1
132 // List-Manager (from Ver8 on)
134 struct WW8LFOInfo;
136 class WW8Reader : public StgReader
138 std::shared_ptr<SvStream> mDecodedStream;
139 virtual ErrCodeMsg Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override;
140 ErrCode OpenMainStream(rtl::Reference<SotStorageStream>& rRef, sal_uInt16& rBuffSize);
141 ErrCode DecryptDRMPackage();
142 public:
143 WW8Reader() {}
144 virtual SwReaderType GetReaderType() override;
146 virtual bool HasGlossaries() const override;
147 virtual bool ReadGlossaries( SwTextBlocks&, bool bSaveRelFiles ) const override;
150 class SwWW8ImplReader;
151 struct WW8LSTInfo;
152 class WW8ListManager
154 public:
155 WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_);
156 //Min and Max possible List Levels in Word
157 enum ListLevel {nMinLevel=1, nMaxLevel=9};
158 //the rParaSprms returns back the original word paragraph indent
159 //sprms which were attached to the original numbering format
160 SwNumRule* GetNumRuleForActivation(sal_uInt16 nLFOPosition, const sal_uInt8 nLevel,
161 std::vector<sal_uInt8> &rParaSprms, SwTextNode *pNode=nullptr);
162 SwNumRule* CreateNextRule(bool bSimple);
163 ~WW8ListManager();
164 SwNumRule* GetNumRule(size_t i);
165 size_t GetWW8LSTInfoNum() const{return maLSTInfos.size();}
166 static SvxNumType GetSvxNumTypeFromMSONFC(sal_uInt16 nMSONFC);
168 private:
169 wwSprmParser maSprmParser;
170 SwWW8ImplReader& m_rReader;
171 SwDoc& m_rDoc;
172 const WW8Fib& m_rFib;
173 SvStream& m_rSt;
174 std::vector<std::unique_ptr<WW8LSTInfo>> maLSTInfos;
175 std::vector<std::unique_ptr<WW8LFOInfo>> m_LFOInfos;// D. from PLF LFO, sorted exactly like in the WW8 Stream
176 sal_uInt16 m_nUniqueList; // current number for creating unique list names
177 SprmResult GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms, sal_uInt8 nLen);
178 WW8LSTInfo* GetLSTByListId( sal_uInt32 nIdLst ) const;
179 //the rParaSprms returns back the original word paragraph indent
180 //sprms which are attached to this numbering level
181 bool ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet>& rpItemSet, sal_uInt16 nLevelStyle,
182 bool bSetStartNo, sal_uInt16 nLevel, ww::bytes &rParaSprms);
184 // character attributes from GrpprlChpx
185 typedef std::unique_ptr<SfxItemSet> WW8aISet[nMaxLevel];
186 // character style pointer
187 typedef SwCharFormat* WW8aCFormat[nMaxLevel];
189 void AdjustLVL(sal_uInt8 nLevel, SwNumRule& rNumRule, WW8aISet const & rListItemSet,
190 WW8aCFormat& aCharFormat, bool& bNewCharFormatCreated,
191 const OUString& aPrefix = OUString());
193 void ImplDestroy();
195 WW8ListManager(const WW8ListManager&) = delete;
196 WW8ListManager& operator=(const WW8ListManager&) = delete;
197 sal_uInt16 m_nLastLFOPosition;
200 struct WW8FlyPara
201 { // WinWord-attributes
202 // Attention: *DO NOT* reorder, since parts will be
203 // compared using memcmp
204 bool bVer67;
205 sal_Int16 nTDxaAbs, nTDyaAbs; // raw position
206 sal_Int16 nSp45, nSp28; // width / height
207 sal_Int16 nLeftMargin, nRightMargin, nUpperMargin, nLowerMargin; // borders
208 sal_uInt8 nTPc; // raw binding + alignment
209 sal_uInt8 nPWr; // Wrap-Mode ( 1 / 2; 0 = no Apo ? )
210 WW8_BRCVer9_5 brc; // borders Top, Left, Bottom, Right, Between
211 bool bBorderLines; // border lines
212 bool bGrafApo; // true: this frame is only used to position
213 // the contained graphics *not* as a character
214 bool mbVertSet; // true if vertical positioning has been set
216 WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc = nullptr);
217 bool operator==(const WW8FlyPara& rSrc) const;
218 void Read(sal_uInt8 nSprmTPc, WW8PLCFx_Cp_FKP* pPap);
219 void ReadFull(sal_uInt8 nOrigSprmTPc, SwWW8ImplReader* pIo);
220 void Read(sal_uInt8 nSprmTPc, WW8RStyle const * pStyle);
221 void ApplyTabPos(const WW8_TablePos *pTabPos);
222 bool IsEmpty() const;
225 class SwWW8StyInf
227 OUString m_sWWStyleName;
228 sal_uInt16 m_nWWStyleId;
229 public:
230 rtl_TextEncoding m_eLTRFontSrcCharSet; // rtl_TextEncoding for the font
231 rtl_TextEncoding m_eRTLFontSrcCharSet; // rtl_TextEncoding for the font
232 rtl_TextEncoding m_eCJKFontSrcCharSet; // rtl_TextEncoding for the font
233 SwFormat* m_pFormat;
234 std::shared_ptr<WW8FlyPara> m_xWWFly;
235 SwNumRule* m_pOutlineNumrule;
236 tools::Long m_nFilePos;
237 sal_uInt16 m_nBase;
238 sal_uInt16 m_nFollow;
239 sal_uInt16 m_nLFOIndex;
240 sal_uInt8 m_nListLevel;
242 // WW8 outline level is zero-based:
243 // 0: outline level 1
244 // 1: outline level 2
245 // ...
246 // 8: outline level 9
247 // 9: body text
248 sal_uInt8 mnWW8OutlineLevel;
250 sal_uInt16 m_n81Flags; // for bold, italic, ...
251 sal_uInt16 m_n81BiDiFlags; // for bold, italic, ...
252 std::shared_ptr<SvxFirstLineIndentItem> m_pWordFirstLine;
253 std::shared_ptr<SvxTextLeftMarginItem> m_pWordLeftMargin;
254 std::shared_ptr<SvxRightMarginItem> m_pWordRightMargin;
255 bool m_bValid; // empty of valid
256 bool m_bImported; // for recursive imports
257 bool m_bColl; // true-> pFormat is SwTextFormatColl
258 bool m_bImportSkipped; // only true if !bNewDoc && existing style
259 bool m_bHasStyNumRule; // true-> named NumRule in style
260 bool m_bHasBrokenWW6List; // true-> WW8+ style has a WW7- list
261 bool m_bListRelevantIndentSet; //true if this style's indent has
262 //been explicitly set, it's set to the value
263 //of pFormat->GetItemState(RES_LR_SPACE, false)
264 //if it was possible to get the ItemState
265 //for L of the LR space independently
266 bool m_bParaAutoBefore; // For Auto spacing before a paragraph
267 bool m_bParaAutoAfter; // For Auto Spacing after a paragraph
268 sal_Int16 m_nRelativeJustify;
270 SwWW8StyInf() :
271 m_sWWStyleName( OUString() ),
272 m_nWWStyleId( 0 ),
273 m_eLTRFontSrcCharSet(0),
274 m_eRTLFontSrcCharSet(0),
275 m_eCJKFontSrcCharSet(0),
276 m_pFormat( nullptr ),
277 m_pOutlineNumrule( nullptr ),
278 m_nFilePos( 0 ),
279 m_nBase( 0 ),
280 m_nFollow( 0 ),
281 m_nLFOIndex( USHRT_MAX ),
282 m_nListLevel(MAXLEVEL),
283 mnWW8OutlineLevel( MAXLEVEL ),
284 m_n81Flags( 0 ),
285 m_n81BiDiFlags(0),
286 m_pWordFirstLine(std::make_shared<SvxFirstLineIndentItem>(RES_MARGIN_FIRSTLINE)),
287 m_pWordLeftMargin(std::make_shared<SvxTextLeftMarginItem>(RES_MARGIN_TEXTLEFT)),
288 m_pWordRightMargin(std::make_shared<SvxRightMarginItem>(RES_MARGIN_RIGHT)),
289 m_bValid(false),
290 m_bImported(false),
291 m_bColl(false),
292 m_bImportSkipped(false),
293 m_bHasStyNumRule(false),
294 m_bHasBrokenWW6List(false),
295 m_bListRelevantIndentSet(false),
296 m_bParaAutoBefore(false),
297 m_bParaAutoAfter(false),
298 m_nRelativeJustify(-1)
302 void SetOrgWWIdent( const OUString& rName, const sal_uInt16 nId )
304 m_sWWStyleName = rName;
305 m_nWWStyleId = nId;
307 // apply default WW8 outline level to WW8 Built-in Heading styles
308 if (IsWW8BuiltInHeadingStyle())
310 mnWW8OutlineLevel = m_nWWStyleId - 1;
314 const OUString& GetOrgWWName() const
316 return m_sWWStyleName;
319 bool HasWW8OutlineLevel() const
321 return (m_pFormat != nullptr && (MAXLEVEL > mnWW8OutlineLevel));
324 bool IsOutlineNumbered() const
326 return m_pOutlineNumrule && HasWW8OutlineLevel();
329 const SwNumRule* GetOutlineNumrule() const
331 return m_pOutlineNumrule;
333 rtl_TextEncoding GetCharSet() const;
334 rtl_TextEncoding GetCJKCharSet() const;
336 sal_uInt16 GetWWStyleId() const
338 return m_nWWStyleId;
341 bool IsWW8BuiltInHeadingStyle() const
343 return GetWWStyleId() >= 1 && GetWWStyleId() <= 9;
346 bool IsWW8BuiltInDefaultStyle() const
348 return GetWWStyleId() == 0;
351 static sal_uInt8
352 WW8OutlineLevelToOutlinelevel(const sal_uInt8 nWW8OutlineLevel)
354 if (nWW8OutlineLevel < MAXLEVEL)
356 if (nWW8OutlineLevel == 9)
358 return 0; // no outline level --> body text
360 else
362 return nWW8OutlineLevel + 1; // outline level 1..9
366 return 0;
370 // Stack
372 class SwWW8FltControlStack : public SwFltControlStack
374 private:
375 SwWW8ImplReader& m_rReader;
376 std::unique_ptr<SfxItemSet> m_xScratchSet;
377 sal_uInt16 m_nToggleAttrFlags;
378 sal_uInt16 m_nToggleBiDiAttrFlags;
379 SwWW8FltControlStack(const SwWW8FltControlStack&) = delete;
380 SwWW8FltControlStack& operator=(const SwWW8FltControlStack&) = delete;
381 const SwNumFormat* GetNumFormatFromStack(const SwPosition &rPos,
382 const SwTextNode &rTextNode);
383 protected:
384 virtual void SetAttrInDoc(const SwPosition& rTmpPos,
385 SwFltStackEntry& rEntry) override;
387 public:
388 SwWW8FltControlStack(SwDoc& rDo, sal_uLong nFieldFl, SwWW8ImplReader& rReader_ )
389 : SwFltControlStack( rDo, nFieldFl ), m_rReader( rReader_ ),
390 m_nToggleAttrFlags(0), m_nToggleBiDiAttrFlags(0)
393 void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
395 virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand=LONG_MAX, bool consumedByField=false) override;
397 void SetToggleAttr(sal_uInt8 nId, bool bOn)
399 if( bOn )
400 m_nToggleAttrFlags |= (1 << nId);
401 else
402 m_nToggleAttrFlags &= ~(1 << nId);
405 sal_uInt16 GetToggleAttrFlags() const { return m_nToggleAttrFlags; }
407 void SetToggleBiDiAttr(sal_uInt8 nId, bool bOn)
409 if( bOn )
410 m_nToggleBiDiAttrFlags |= (1 << nId);
411 else
412 m_nToggleBiDiAttrFlags &= ~(1 << nId);
415 sal_uInt16 GetToggleBiDiAttrFlags() const { return m_nToggleBiDiAttrFlags; }
416 void SetToggleAttrFlags(sal_uInt16 nFlags) { m_nToggleAttrFlags = nFlags; }
417 void SetToggleBiDiAttrFlags(sal_uInt16 nFlags) {m_nToggleBiDiAttrFlags = nFlags;}
419 const SfxPoolItem* GetFormatAttr(const SwPosition& rPos, sal_uInt16 nWhich);
420 template<class T> const T* GetFormatAttr( const SwPosition& rPos, TypedWhichId<T> nWhich )
422 return static_cast<const T*>(GetFormatAttr(rPos, sal_uInt16(nWhich)));
424 const SfxPoolItem* GetStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
427 //The only thing this is for is RES_FLTR_ANCHOR, anything else is an error.
428 //For graphics whose anchoring position would otherwise be automatically moved
429 //along by the insertion of text.
430 class SwWW8FltAnchorStack : public SwFltControlStack
432 public:
433 SwWW8FltAnchorStack(SwDoc& rDo, sal_uLong nFieldFl)
434 : SwFltControlStack( rDo, nFieldFl ) {}
435 void AddAnchor(const SwPosition& rPos,SwFrameFormat *pFormat);
436 void Flush();
437 private:
438 SwWW8FltAnchorStack(const SwWW8FltAnchorStack&) = delete;
439 SwWW8FltAnchorStack& operator=(const SwWW8FltAnchorStack&) = delete;
443 namespace SwWW8
445 struct ltstr
447 bool operator()(std::u16string_view r1, std::u16string_view r2) const
449 return o3tl::compareToIgnoreAsciiCase(r1, r2)<0;
454 class SwWW8ReferencedFltEndStack : public SwFltEndStack
456 public:
457 SwWW8ReferencedFltEndStack( SwDoc& rDo, sal_uLong nFieldFl )
458 : SwFltEndStack( rDo, nFieldFl )
459 , m_aReferencedTOCBookmarks()
462 // Keep track of referenced TOC bookmarks in order to suppress the import
463 // of unreferenced ones.
464 std::set<OUString, SwWW8::ltstr> m_aReferencedTOCBookmarks;
465 protected:
466 virtual void SetAttrInDoc( const SwPosition& rTmpPos,
467 SwFltStackEntry& rEntry ) override;
470 class SwWW8FltRefStack final : public SwFltEndStack
472 public:
473 SwWW8FltRefStack(SwDoc& rDo, sal_uLong nFieldFl)
474 : SwFltEndStack( rDo, nFieldFl )
475 , m_aFieldVarNames()
477 bool IsFootnoteEdnBkmField(const SwFormatField& rFormatField, sal_uInt16& rBkmNo);
479 //Keep track of variable names created with fields, and the bookmark
480 //mapped to their position, hopefully the same, but very possibly
481 //an additional pseudo bookmark
482 std::map<OUString, OUString, SwWW8::ltstr> m_aFieldVarNames;
483 private:
484 SwFltStackEntry *RefToVar(const SwField* pField,SwFltStackEntry& rEntry);
485 virtual void SetAttrInDoc(const SwPosition& rTmpPos,
486 SwFltStackEntry& rEntry) override;
487 SwWW8FltRefStack(const SwWW8FltRefStack&) = delete;
488 SwWW8FltRefStack& operator=(const SwWW8FltRefStack&) = delete;
491 template< typename Type >
492 inline bool get_flag( Type nBitField, Type nMask )
493 { return (nBitField & nMask) != 0; }
495 template< typename ReturnType, typename Type >
496 inline ReturnType ulimit_cast( Type nValue, ReturnType nMax )
497 { return static_cast< ReturnType >( std::min< Type >( nValue, nMax ) ); }
499 template< typename ReturnType, typename Type >
500 inline ReturnType ulimit_cast( Type nValue )
501 { return ulimit_cast( nValue, std::numeric_limits< ReturnType >::max() ); }
503 class SwMacroInfo : public SdrObjUserData
505 public:
506 SwMacroInfo();
507 virtual ~SwMacroInfo() override;
509 SwMacroInfo(SwMacroInfo const &) = default;
510 SwMacroInfo(SwMacroInfo &&) = default;
511 SwMacroInfo & operator =(SwMacroInfo const &) = delete; // due to SdrObjUserData
512 SwMacroInfo & operator =(SwMacroInfo &&) = delete; // due to SdrObjUserData
514 virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override;
516 void SetHlink( const OUString& rHlink ) { maHlink = rHlink; }
517 const OUString& GetHlink() const { return maHlink; }
518 void SetTarFrame( const OUString& rTarFrame ) { maTarFrame = rTarFrame; }
519 const OUString& GetTarFrame() const { return maTarFrame; }
520 void SetShapeId( sal_Int32 rShapeId ) { mnShapeId = rShapeId; }
521 const sal_Int32& GetShapeId() const { return mnShapeId; }
522 void SetName( const OUString& rName ) { maNameStr = rName; }
523 const OUString& GetName() const { return maNameStr; }
525 private:
526 sal_Int32 mnShapeId;
527 OUString maHlink;
528 OUString maNameStr;
529 OUString maTarFrame;
532 struct HyperLinksTable
534 OUString hLinkAddr;
535 OUString tarFrame;
538 namespace sw
540 namespace hack
542 class Position
544 private:
545 SwNodeIndex maPtNode;
546 sal_Int32 mnPtContent;
547 public:
548 explicit Position(const SwPosition &rPos);
549 operator SwPosition() const;
550 const SwNodeIndex& GetPtNode() const { return maPtNode; };
551 sal_Int32 GetPtContent() const { return mnPtContent; };
555 auto FilterControlChars(std::u16string_view aString) -> OUString;
558 class WW8FieldEntry
560 private:
561 OUString msBookmarkName;
562 OUString msMarkType;
563 OUString msMarkCode;
564 ::sw::mark::Fieldmark::parameter_map_t maParams;
566 public:
567 sw::hack::Position maStartPos;
568 sal_uInt16 mnFieldId;
569 sal_uLong mnObjLocFc;
570 WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) noexcept;
571 WW8FieldEntry(const WW8FieldEntry &rOther) noexcept;
572 WW8FieldEntry &operator=(const WW8FieldEntry &rOther) noexcept;
573 void Swap(WW8FieldEntry &rOther) noexcept;
575 const SwNodeIndex& GetPtNode() const { return maStartPos.GetPtNode(); };
576 sal_Int32 GetPtContent() const { return maStartPos.GetPtContent(); };
578 const OUString& GetBookmarkName() const { return msBookmarkName;}
579 const OUString& GetBookmarkCode() const { return msMarkCode;}
580 void SetBookmarkName(const OUString& bookmarkName);
581 void SetBookmarkType(const OUString& bookmarkType);
582 void SetBookmarkCode(const OUString& bookmarkCode);
583 ::sw::mark::Fieldmark::parameter_map_t& getParameters() { return maParams;}
586 // mini marker for some flags
588 class WW8ReaderSave
590 private:
591 WW8PLCFxSaveAll maPLCFxSave;
592 std::shared_ptr<SwUnoCursor> mxTmpPos;
593 std::deque<bool> maOldApos;
594 std::deque<WW8FieldEntry> maOldFieldStack;
595 std::unique_ptr<SwWW8FltControlStack> mxOldStck;
596 std::unique_ptr<SwWW8FltAnchorStack> mxOldAnchorStck;
597 std::unique_ptr<sw::util::RedlineStack> mxOldRedlines;
598 std::shared_ptr<WW8PLCFMan> mxOldPlcxMan;
599 std::unique_ptr<WW8FlyPara> mpWFlyPara;
600 std::unique_ptr<WW8SwFlyPara> mpSFlyPara;
601 SwPaM* mpPreviousNumPaM;
602 const SwNumRule* mpPrevNumRule;
603 std::unique_ptr<WW8TabDesc> mxTableDesc;
604 int mnInTable;
605 sal_uInt16 mnCurrentColl;
606 sal_Unicode mcSymbol;
607 bool mbIgnoreText;
608 bool mbSymbol;
609 bool mbHdFtFootnoteEdn;
610 bool mbTxbxFlySection;
611 bool mbAnl;
612 bool mbInHyperlink;
613 bool mbPgSecBreak;
614 bool mbWasParaEnd;
615 bool mbHasBorder;
616 bool mbFirstPara;
617 public:
618 WW8ReaderSave(SwWW8ImplReader* pRdr, WW8_CP nStart=-1);
619 void Restore(SwWW8ImplReader* pRdr);
620 const SwPosition &GetStartPos() const { return *mxTmpPos->GetPoint(); }
623 enum class eF_ResT { OK, TEXT, TAGIGN, READ_FSPA };
625 class SwWW8Shade
627 public:
628 Color m_aColor;
629 SwWW8Shade(bool bVer67, const WW8_SHD& rSHD);
630 SwWW8Shade(Color nFore, Color nBack, sal_uInt16 nIndex)
632 SetShade(nFore, nBack, nIndex);
634 private:
635 void SetShade(Color nFore, Color nBack, sal_uInt16 nIndex);
638 // Formulas
640 enum SwWw8ControlType
642 WW8_CT_EDIT,
643 WW8_CT_CHECKBOX,
644 WW8_CT_DROPDOWN
647 class WW8FormulaControl
649 protected:
650 SwWW8ImplReader &mrRdr;
652 WW8FormulaControl(WW8FormulaControl const&) = delete;
653 WW8FormulaControl& operator=(WW8FormulaControl const&) = delete;
655 public:
656 WW8FormulaControl(OUString aN, SwWW8ImplReader &rRdr)
657 : mrRdr(rRdr), mfUnknown(0), mfDropdownIndex(0),
658 mfToolTip(0), mfNoMark(0), mfType(0),
659 mfUnused(0), mhpsCheckBox(20), mnChecked(0), mnMaxLen(0),
660 mbHelp(false), msName(std::move( aN ))
663 sal_uInt8 mfUnknown:2;
664 sal_uInt8 mfDropdownIndex:6;
665 sal_uInt8 mfToolTip:1;
666 sal_uInt8 mfNoMark:1;
667 sal_uInt8 mfType:3;
668 sal_uInt8 mfUnused:3;
670 sal_uInt16 mhpsCheckBox;
671 sal_uInt16 mnChecked;
673 /// FFData.cch in the spec: maximum length, in characters, of the value of the textbox.
674 sal_uInt16 mnMaxLen;
675 OUString msTitle;
676 OUString msDefault;
677 OUString msFormatting;
678 bool mbHelp;
679 OUString msHelp;
680 OUString msToolTip;
681 OUString msEntryMcr;
682 OUString msExitMcr;
683 std::vector<OUString> maListEntries;
684 virtual ~WW8FormulaControl() {}
685 void FormulaRead(SwWw8ControlType nWhich,SvStream *pD);
686 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
687 css::uno::Reference< css::form::XFormComponent> &rFComp,
688 css::awt::Size &rSz) = 0;
689 OUString msName;
692 class WW8FormulaCheckBox : public WW8FormulaControl
694 private:
695 WW8FormulaCheckBox(const WW8FormulaCheckBox&) = delete;
696 WW8FormulaCheckBox& operator=(const WW8FormulaCheckBox&) = delete;
698 public:
699 explicit WW8FormulaCheckBox(SwWW8ImplReader &rR);
701 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
702 css::uno::Reference< css::form::XFormComponent> &rFComp,
703 css::awt::Size &rSz) override;
706 class WW8FormulaListBox : public WW8FormulaControl
708 private:
709 WW8FormulaListBox(const WW8FormulaListBox&) = delete;
710 WW8FormulaListBox& operator=(const WW8FormulaListBox&) = delete;
712 public:
713 explicit WW8FormulaListBox(SwWW8ImplReader &rR);
715 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
716 css::uno::Reference< css::form::XFormComponent> &rFComp,
717 css::awt::Size &rSz) override;
720 class WW8FormulaEditBox : public WW8FormulaControl
722 private:
723 WW8FormulaEditBox(const WW8FormulaEditBox&) = delete;
724 WW8FormulaEditBox& operator=(const WW8FormulaEditBox&) = delete;
725 public:
726 explicit WW8FormulaEditBox(SwWW8ImplReader &rR);
727 //no real implementation, return false
728 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> & /* rServiceFactory */,
729 css::uno::Reference< css::form::XFormComponent> & /* rFComp */,
730 css::awt::Size & /* rSz */) override { return false; }
733 class SwMSConvertControls: public oox::ole::MSConvertOCXControls
735 public:
736 SwMSConvertControls( SfxObjectShell const *pDSh, SwPaM *pP );
737 void InsertFormula( WW8FormulaControl &rFormula);
738 virtual bool InsertControl(const css::uno::Reference< css::form::XFormComponent >& rFComp,
739 const css::awt::Size& rSize,
740 css::uno::Reference< css::drawing::XShape > *pShape, bool bFloatingCtrl) override;
741 void ExportControl(WW8Export &rWrt, const SdrUnoObj& rFormObj);
742 bool ReadOCXStream(rtl::Reference<SotStorage> const& rSrc1,
743 css::uno::Reference< css::drawing::XShape > *pShapeRef,
744 bool bFloatingCtrl=false );
745 private:
746 SwPaM *m_pPaM;
747 sal_uInt32 mnObjectId;
750 class SwMSDffManager : public SvxMSDffManager
752 private:
753 SwWW8ImplReader& m_rReader;
754 SvStream *m_pFallbackStream;
755 std::unordered_map<sal_uInt32, Graphic> m_aOldEscherBlipCache;
757 virtual bool GetOLEStorageName( sal_uInt32 nOLEId, OUString& rStorageName,
758 rtl::Reference<SotStorage>& rSrcStorage, css::uno::Reference < css::embed::XStorage >& rDestStorage ) const override;
759 virtual bool ShapeHasText( sal_uLong nShapeId, sal_uLong nFilePos ) const override;
760 // #i32596# - new parameter <_nCalledByGroup>, which
761 // indicates, if the OLE object is imported inside a group object
762 virtual rtl::Reference<SdrObject> ImportOLE( sal_uInt32 nOLEId,
763 const Graphic& rGrf,
764 const tools::Rectangle& rBoundRect,
765 const tools::Rectangle& rVisArea,
766 const int _nCalledByGroup ) const override;
768 SwMSDffManager(const SwMSDffManager&) = delete;
769 SwMSDffManager& operator=(const SwMSDffManager&) = delete;
770 public:
771 static sal_uInt32 GetFilterFlags();
772 static sal_Int32 GetEscherLineMatch(MSO_LineStyle eStyle, MSO_SPT eShapeType,
773 sal_Int32 &rThick);
774 SwMSDffManager( SwWW8ImplReader& rRdr, bool bSkipImages );
775 void DisableFallbackStream();
776 void EnableFallbackStream();
777 protected:
778 virtual rtl::Reference<SdrObject> ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
781 class wwSection
783 public:
784 explicit wwSection(const SwPosition &rPos);
785 SEPr maSep;
786 WW8_BRCVer9 m_brc[4];
787 SwNodeIndex maStart;
788 SwSection *mpSection;
789 SwPageDesc *mpPage;
790 SvxFrameDirection meDir;
792 sal_uInt32 m_nPgWidth;
793 sal_uInt32 m_nPgLeft;
794 sal_uInt32 m_nPgRight;
795 sal_uInt32 m_nPgGutter;
796 bool m_bRtlGutter = false;
798 css::drawing::TextVerticalAdjust mnVerticalAdjustment;
799 sal_uInt8 mnBorders;
800 bool mbHasFootnote;
801 void SetDirection();
802 bool IsContinuous() const { return maSep.bkc == 0; }
803 bool IsNotProtected() const { return maSep.fUnlocked != 0; }
804 bool IsVertical() const;
805 sal_Int16 NoCols() const { return maSep.ccolM1 + 1; }
806 sal_Int32 StandardColSeparation() const { return maSep.dxaColumns; }
807 bool HasTitlePage() const { return maSep.fTitlePage != 0; }
808 sal_uInt16 PageStartAt() const { return maSep.pgnStart; }
809 bool PageRestartNo() const { return maSep.fPgnRestart != 0; }
810 bool IsBiDi() const { return maSep.fBiDi != 0; }
811 sal_uInt32 GetPageWidth() const { return m_nPgWidth; }
812 sal_uInt32 GetTextAreaWidth() const
813 { return GetPageWidth() - GetPageLeft() - m_nPgGutter - GetPageRight(); }
814 sal_uInt32 GetPageHeight() const { return maSep.yaPage; }
815 sal_uInt32 GetPageLeft() const { return m_nPgLeft; }
816 sal_uInt32 GetPageRight() const { return m_nPgRight; }
817 bool IsLandScape() const { return maSep.dmOrientPage != 0; }
818 bool IsFixedHeightHeader() const { return maSep.dyaTop < 0; }
819 bool IsFixedHeightFooter() const { return maSep.dyaBottom < 0; }
822 class wwSectionManager
824 private:
826 A queue of the ms sections in the document
828 SwWW8ImplReader& mrReader;
829 std::deque<wwSection> maSegments;
830 typedef std::deque<wwSection>::iterator mySegIter;
832 //Num of page desc's entered into the document
833 sal_uInt16 mnDesc;
835 struct wwULSpaceData
837 bool bHasHeader, bHasFooter;
838 sal_uInt32 nSwHLo, nSwFUp, nSwUp, nSwLo;
839 wwULSpaceData()
840 : bHasHeader(false)
841 , bHasFooter(false)
842 , nSwHLo(0)
843 , nSwFUp(0)
844 , nSwUp(0)
845 , nSwLo(0)
849 void SetSegmentToPageDesc(const wwSection &rSection, bool bIgnoreCols);
851 void GetPageULData(const wwSection &rNewSection,
852 wwULSpaceData& rData) const;
853 static void SetPageULSpaceItems(SwFrameFormat &rFormat, wwULSpaceData const & rData,
854 const wwSection &rSection);
856 static void SetPage(SwPageDesc &rPageDesc, SwFrameFormat &rFormat,
857 const wwSection &rSection, bool bIgnoreCols);
859 static void SetNumberingType(const wwSection &rNewSection, SwPageDesc &rPageDesc);
861 void SetUseOn(wwSection &rSection);
862 void SetHdFt(wwSection const &rSection, int nSect, const wwSection *pPrevious);
864 SwSectionFormat *InsertSection(SwPaM const & rMyPaM, wwSection &rSection);
865 static bool SetCols(SwFrameFormat &rFormat, const wwSection &rSection,
866 sal_uInt32 nNetWidth);
867 bool SectionIsProtected(const wwSection &rSection) const;
868 static void SetLeftRight(wwSection &rSection);
870 The segment we're inserting, the start of the segments container, and the
871 nodeindex of where we want the page break to (normally the segments start
872 position
874 SwFormatPageDesc SetSwFormatPageDesc(mySegIter const &rIter, mySegIter const &rStart,
875 bool bIgnoreCols);
877 wwSectionManager(const wwSectionManager&) = delete;
878 wwSectionManager& operator=(const wwSectionManager&) = delete;
879 public:
880 explicit wwSectionManager(SwWW8ImplReader &rReader) : mrReader(rReader), mnDesc(0)
882 void SetCurrentSectionHasFootnote();
883 void SetCurrentSectionVerticalAdjustment(const css::drawing::TextVerticalAdjust nVA);
884 bool CurrentSectionIsVertical() const;
885 bool CurrentSectionIsProtected() const;
886 void PrependedInlineNode(const SwPosition &rPos, const SwNode &rNode);
887 sal_uInt16 CurrentSectionColCount() const;
888 bool WillHavePageDescHere(const SwNode&) const;
889 void CreateSep(const tools::Long nTextPos);
890 void InsertSegments();
891 void JoinNode(const SwPosition &rPos, const SwNode &rNode);
892 sal_uInt32 GetPageLeft() const;
893 sal_uInt32 GetPageRight() const;
894 sal_uInt32 GetPageWidth() const;
895 sal_uInt32 GetWWPageTopMargin() const;
896 sal_uInt32 GetTextAreaWidth() const;
899 class TextNodeListener : public SwClient
901 SwTextNode *m_pTextNode;
903 protected:
904 virtual void SwClientNotify(const SwModify&, const SfxHint&) override;
906 public:
907 TextNodeListener(SwTextNode* pTextNode);
908 bool operator<(const TextNodeListener& rOther) const
910 return m_pTextNode->GetIndex() < rOther.m_pTextNode->GetIndex();
912 void StopListening(SwModify* pTextNode);
913 SwTextNode* GetTextNode() const { return m_pTextNode; }
914 virtual void removed(SwModify* pTextNode);
915 virtual ~TextNodeListener() override;
918 //Various writer elements like frames start off containing a blank paragraph,
919 //sometimes this paragraph turns out to be extraneous, e.g. the frame should
920 //only contain a table with no trailing paragraph.
922 //We want to remove these extra paragraphs, but removing them during the parse
923 //is problematic, because we don't want to remove any paragraphs that are still
924 //addressed by property entries in a SwFltControlStack which have not yet been
925 //committed to the document.
927 //Safest thing is to not delete SwTextNodes from a document during import, and
928 //remove these extraneous paragraphs at the end after all SwFltControlStack are
929 //destroyed.
930 class wwExtraneousParas
932 private:
933 class ExtraTextNodeListener : public TextNodeListener
935 private:
936 wwExtraneousParas* m_pOwner;
937 public:
938 ExtraTextNodeListener(SwTextNode* pTextNode, wwExtraneousParas* pOwner)
939 : TextNodeListener(pTextNode)
940 , m_pOwner(pOwner)
943 virtual void removed(SwModify* pTextNode) override;
947 A vector of SwTextNodes to erase from a document after import is complete
949 std::set<ExtraTextNodeListener> m_aTextNodes;
950 SwDoc& m_rDoc;
952 void remove_if_present(SwModify* pModify);
954 wwExtraneousParas(wwExtraneousParas const&) = delete;
955 wwExtraneousParas& operator=(wwExtraneousParas const&) = delete;
956 public:
957 explicit wwExtraneousParas(SwDoc &rDoc) : m_rDoc(rDoc) {}
958 ~wwExtraneousParas() { delete_all_from_doc(); }
959 void insert(SwTextNode *pTextNode);
960 void remove_if_present(SwTextNode *pTextNode)
962 remove_if_present(static_cast<SwModify*>(pTextNode));
964 void delete_all_from_doc();
967 class wwFrameNamer
969 private:
970 OUString msSeed;
971 sal_Int32 mnImportedGraphicsCount;
972 bool mbIsDisabled;
974 wwFrameNamer(wwFrameNamer const&) = delete;
975 wwFrameNamer& operator=(wwFrameNamer const&) = delete;
977 public:
978 void SetUniqueGraphName(SwFrameFormat *pFrameFormat, std::u16string_view rFixedPart);
979 wwFrameNamer(bool bIsDisabled, OUString aSeed)
980 : msSeed(std::move(aSeed)), mnImportedGraphicsCount(0), mbIsDisabled(bIsDisabled)
985 class wwSectionNamer
987 private:
988 const SwDoc &mrDoc;
989 OUString msFileLinkSeed;
990 int mnFileSectionNo;
991 wwSectionNamer(const wwSectionNamer&) = delete;
992 wwSectionNamer& operator=(const wwSectionNamer&) = delete;
993 public:
994 OUString UniqueName();
995 wwSectionNamer(const SwDoc &rDoc, OUString aSeed)
996 : mrDoc(rDoc), msFileLinkSeed(std::move(aSeed)), mnFileSectionNo(0)
1000 class FootnoteDescriptor
1002 public:
1003 ManTypes meType;
1004 bool mbAutoNum;
1005 WW8_CP mnStartCp;
1006 WW8_CP mnLen;
1009 struct ApoTestResults
1011 bool mbStartApo;
1012 bool mbStopApo;
1013 bool m_bHasSprmPWr;
1014 bool m_bHasSprmPPc;
1015 /// sprmPPc if m_bHasSprmPPc is true, sprmTPc otherwise.
1016 sal_uInt8 m_nSprmPPc;
1017 WW8FlyPara* mpStyleApo;
1018 ApoTestResults()
1019 : mbStartApo(false), mbStopApo(false), m_bHasSprmPWr(false)
1020 , m_bHasSprmPPc(false), m_nSprmPPc(0), mpStyleApo(nullptr) {}
1021 bool HasStartStop() const { return (mbStartApo || mbStopApo); }
1022 bool HasFrame() const { return (m_bHasSprmPPc || m_bHasSprmPWr || mpStyleApo); }
1025 struct ANLDRuleMap
1027 OUString msOutlineNumRule; // WinWord 6 numbering, variant 1
1028 OUString msNumberingNumRule; // WinWord 6 numbering, variant 2
1029 SwNumRule* GetNumRule(const SwDoc& rDoc, sal_uInt8 nNumType);
1030 void SetNumRule(const OUString& rNumRule, sal_uInt8 nNumType);
1033 struct SprmReadInfo;
1034 class SwDocShell;
1035 struct WW8PostProcessAttrsInfo
1037 bool mbCopy;
1038 WW8_CP mnCpStart;
1039 WW8_CP mnCpEnd;
1040 SwPaM mPaM;
1041 SfxItemSet mItemSet;
1043 WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd, SwPaM & rPaM);
1046 #define MAX_COL 64 // WW6-description: 32, WW6-UI: 31 & WW8-UI: 63!
1048 struct WW8TabBandDesc
1050 WW8TabBandDesc* pNextBand;
1051 short nGapHalf;
1052 short mnDefaultLeft;
1053 short mnDefaultTop;
1054 short mnDefaultRight;
1055 short mnDefaultBottom;
1056 bool mbHasSpacing;
1057 short nLineHeight;
1058 short nRows;
1059 sal_uInt16 maDirections[MAX_COL + 1];
1060 short nCenter[MAX_COL + 1]; // X-edge of all cells of this band
1061 short nWidth[MAX_COL + 1]; // length of all cells of this band
1062 short nWwCols; // sal_uInt8 would be sufficient, alignment -> short
1063 short nSwCols; // SW: number of columns for the writer
1064 bool bLEmptyCol; // SW: an additional empty column at the left
1065 bool bREmptyCol; // SW: same at the right
1066 bool bCantSplit;
1067 WW8_TCell* pTCs;
1068 sal_uInt8 nOverrideSpacing[MAX_COL + 1];
1069 short nOverrideValues[MAX_COL + 1][4];
1070 WW8_SHD* pSHDs;
1071 Color* pNewSHDs;
1072 WW8_BRCVer9 aDefBrcs[6];
1074 bool bExist[MAX_COL]; // does this cell exist ?
1075 sal_uInt8 nTransCell[MAX_COL + 2]; // translation WW-Index -> SW-Index
1077 sal_uInt8 transCell(sal_uInt8 nWwCol) const
1079 return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
1082 WW8TabBandDesc();
1083 WW8TabBandDesc(WW8TabBandDesc const & rBand); // deep copy
1084 ~WW8TabBandDesc();
1085 void ReadDef(bool bVer67, const sal_uInt8* pS, short nLen);
1086 void ProcessDirection(const sal_uInt8* pParams);
1087 void ProcessSprmTSetBRC(int nBrcVer, const sal_uInt8* pParamsTSetBRC, sal_uInt16 nParamsLen);
1088 void ProcessSprmTTableBorders(int nBrcVer, const sal_uInt8* pParams, sal_uInt16 nParamsLen);
1089 void ProcessSprmTDxaCol(const sal_uInt8* pParamsTDxaCol);
1090 void ProcessSprmTDelete(const sal_uInt8* pParamsTDelete);
1091 void ProcessSprmTInsert(const sal_uInt8* pParamsTInsert);
1092 void ProcessSpacing(const sal_uInt8* pParamsTInsert);
1093 void ProcessSpecificSpacing(const sal_uInt8* pParamsTInsert);
1094 void ReadShd(const sal_uInt8* pS );
1095 void ReadNewShd(const sal_uInt8* pS, bool bVer67, sal_uInt8 nStart);
1097 enum wwDIR {wwTOP = 0, wwLEFT = 1, wwBOTTOM = 2, wwRIGHT = 3};
1099 private:
1100 WW8TabBandDesc & operator =(WW8TabBandDesc const &) = default; // only for use in copy ctor
1103 // Storage-Reader
1105 typedef std::set<WW8_CP> cp_set;
1107 class SwWW8ImplReader
1109 private:
1110 SwDocShell *m_pDocShell; // The Real DocShell
1112 friend class WW8RStyle;
1113 friend class WW8TabDesc;
1114 friend class WW8ReaderSave;
1115 friend struct WW8FlyPara;
1116 friend struct WW8SwFlyPara;
1117 friend class WW8FlySet;
1118 friend class SwMSDffManager;
1119 friend class SwWW8FltControlStack;
1120 friend class WW8FormulaControl;
1121 friend class wwSectionManager;
1123 private:
1125 SotStorage* m_pStg; // Input-Storage
1126 SvStream* m_pStrm; // Input-(Storage)Stream
1127 SvStream* m_pTableStream; // Input-(Storage)Stream
1128 SvStream* m_pDataStream; // Input-(Storage)Stream
1130 // general stuff
1131 SwDoc& m_rDoc;
1132 std::shared_ptr<SwUnoCursor> mpCursor;
1133 SwPaM* m_pPaM;
1135 std::unique_ptr<SwWW8FltControlStack> m_xCtrlStck; // stack for the attributes
1138 This stack is for redlines, because their sequence of discovery can
1139 be out of order of their order of insertion into the document.
1141 std::unique_ptr<sw::util::RedlineStack> m_xRedlineStack;
1144 This stack is for fields that get referenced later, e.g. BookMarks and TOX.
1145 They get inserted at the end of the document, it is the same stack for
1146 headers/footers/main text/textboxes/tables etc...
1148 std::unique_ptr<SwWW8ReferencedFltEndStack> m_xReffedStck;
1151 This stack is for fields whose true conversion cannot be determined until
1152 the end of the document, it is the same stack for headers/footers/main
1153 text/textboxes/tables etc... They are things that reference other things
1154 e.g. NoteRef and Ref, they are processed after m_xReffedStck
1156 std::unique_ptr<SwWW8FltRefStack> m_xReffingStck;
1159 For graphics anchors. Determines the graphics whose anchors are in the
1160 current paragraph, and works around the difficulty in inserting a graphic
1161 anchored to character before a character to be anchored to has been
1162 inserted. Is emptied at the end of each paragraph.
1164 std::unique_ptr<SwWW8FltAnchorStack> m_xAnchorStck;
1167 A stack of fields identifiers to keep track of any open fields that need
1168 to be closed. Generally word fields are inserted as writer fields as soon
1169 as they are encountered, and so their end point is normally unimportant.
1170 But hyperlink fields need to be applied as attributes to text and it is
1171 far easier and safer to set the end point of an attribute when we
1172 encounter the end marker of the field instead of calculating in advance
1173 where the end point will fall, to do so fully correctly duplicates the
1174 main logic of the filter itself.
1176 std::deque<WW8FieldEntry> m_aFieldStack;
1179 A stack of open footnotes. Should only be one in it at any time.
1181 std::deque<FootnoteDescriptor> m_aFootnoteStack;
1183 std::optional<SwLineBreakClear> m_oLineBreakClear;
1186 A queue of the ms sections in the document
1188 wwSectionManager m_aSectionManager;
1191 A vector of surplus-to-requirements paragraph in the final document,
1192 that exist because of quirks of the SwDoc document model and/or API,
1193 which need to be removed.
1195 wwExtraneousParas m_aExtraneousParas;
1198 A map of tables to their follow nodes for use in inserting tables into
1199 already existing document, i.e. insert file
1201 sw::util::InsertedTablesManager m_aInsertedTables;
1204 Creates unique names to give to (file link) sections (WW1/WW2/...)
1206 wwSectionNamer m_aSectionNameGenerator;
1209 Knows how to split a series of bytes into sprms and their arguments
1211 std::optional<wwSprmParser> m_oSprmParser;
1214 Creates unique names to give to graphics
1216 wwFrameNamer m_aGrfNameGenerator;
1219 Knows which writer style a given word style should be imported as.
1221 sw::util::ParaStyleMapper m_aParaStyleMapper;
1222 sw::util::CharStyleMapper m_aCharStyleMapper;
1225 Stack of textencoding being used as we progress through the document text
1227 std::stack<rtl_TextEncoding> m_aFontSrcCharSets;
1228 std::stack<rtl_TextEncoding> m_aFontSrcCJKCharSets;
1231 Progress bar
1233 std::unique_ptr<ImportProgress> m_xProgress;
1235 std::unique_ptr<SwMSConvertControls> m_xFormImpl; // implementation of control
1237 SwFlyFrameFormat* m_pFlyFormatOfJustInsertedGraphic;
1238 std::unique_ptr<FrameDeleteWatch> m_xFormatOfJustInsertedApo;
1239 SwPaM* m_pPreviousNumPaM;
1240 const SwNumRule* m_pPrevNumRule;
1242 //Keep track of APO environments
1243 std::deque<bool> m_aApos;
1245 Keep track of generated Ruby character formats we can minimize the
1246 number of character formats created
1248 std::vector<const SwCharFormat*> m_aRubyCharFormats;
1251 For fuzzing keep track of source offset of inserted graphics
1253 std::set<sal_uLong> m_aGrafPosSet;
1255 std::unique_ptr<WW8PostProcessAttrsInfo> m_pPostProcessAttrsInfo;
1257 std::shared_ptr<WW8Fib> m_xWwFib;
1258 std::unique_ptr<WW8Fonts> m_xFonts;
1259 std::unique_ptr<WW8Dop> m_xWDop;
1260 std::unique_ptr<WW8ListManager> m_xLstManager;
1261 std::unique_ptr<WW8ScannerBase> m_xSBase;
1262 std::shared_ptr<WW8PLCFMan> m_xPlcxMan;
1263 std::map<short, OUString> m_aLinkStringMap;
1265 o3tl::sorted_vector<const SwNode*> m_aTextNodesHavingFirstLineOfstSet; // #i103711#
1266 o3tl::sorted_vector<const SwNode*> m_aTextNodesHavingLeftIndentSet; // #i105414#
1268 std::unique_ptr<WW8RStyle> m_xStyles; // pointer to the style reading class
1269 SwFormat* m_pCurrentColl; // collection to be created now
1270 // ( always 0 outside of a Style-Def )
1271 std::unique_ptr<SfxItemSet> m_xCurrentItemSet;// character attributes to be read in now
1272 // (always 0 outside of the WW8ListManager Ctor)
1273 std::vector<SwWW8StyInf> m_vColl;
1274 const SwTextFormatColl* m_pDfltTextFormatColl; // Default
1275 SwFormat* m_pStandardFormatColl;// "Standard"
1277 std::unique_ptr<WW8PLCF_HdFt> m_xHdFt; // pointer to Header / Footer - scanner class
1279 std::unique_ptr<WW8FlyPara> m_xWFlyPara; // WW-parameter
1280 std::unique_ptr<WW8SwFlyPara> m_xSFlyPara; // Sw parameters created from previous
1282 std::unique_ptr<WW8TabDesc> m_xTableDesc; // description of table properties
1283 //Keep track of tables within tables
1284 std::stack<std::unique_ptr<WW8TabDesc>> m_aTableStack;
1286 ANLDRuleMap m_aANLDRules;
1287 std::unique_ptr<WW8_OLST> m_xNumOlst; // position in text
1289 SdrModel* m_pDrawModel;
1290 SdrPage* m_pDrawPg;
1291 std::unique_ptr<EditEngine> m_pDrawEditEngine;
1292 std::unique_ptr<wwZOrderer> m_xWWZOrder;
1294 SwSetExpFieldType* m_pNumFieldType; // for number circle
1296 std::unique_ptr<SwMSDffManager> m_xMSDffManager;
1298 std::optional<std::vector<OUString>> m_xAtnNames;
1300 std::unique_ptr<WW8SmartTagData> m_pSmartTagData;
1302 /// Redlining Authors, map word author key to writer author value
1303 std::map<sal_uInt16, std::size_t> m_aAuthorInfos;
1304 OUString m_sBaseURL;
1306 // Ini-Flags:
1307 sal_uInt32 m_nIniFlags; // flags from writer.ini
1308 sal_uInt32 m_nIniFlags1; // ditto ( additional flags )
1309 sal_uInt32 m_nFieldFlags; // ditto for fields
1310 static constexpr size_t FieldTagSize = 3;
1311 sal_uInt32 m_nFieldTagAlways[FieldTagSize]; // ditto for tagging of fields
1312 sal_uInt32 m_nFieldTagBad[FieldTagSize]; // ditto for tagging of fields that can't be imported
1313 bool m_bRegardHindiDigits; // import digits in CTL scripts as Hindi numbers
1315 bool m_bDrawCpOValid;
1316 WW8_CP m_nDrawCpO; // start of Txbx-SubDocs
1318 sal_uLong m_nPicLocFc; // Picture Location in File (FC)
1319 sal_uLong m_nObjLocFc; // Object Location in File (FC)
1321 sal_Int32 m_nIniFlyDx; // X-offset of Flys
1322 sal_Int32 m_nIniFlyDy; // Y-offset of Flys
1324 rtl_TextEncoding m_eTextCharSet; // Default charset for Text
1325 rtl_TextEncoding m_eStructCharSet; // rtl_TextEncoding for structures
1326 rtl_TextEncoding m_eHardCharSet; // Hard rtl_TextEncoding-Attribute
1327 sal_uInt16 m_nProgress; // percentage for Progressbar
1328 sal_uInt16 m_nCurrentColl; // per WW-count
1329 sal_uInt16 m_nFieldNum; // serial number for that
1330 sal_uInt16 m_nLFOPosition;
1332 short m_nCharFormat; // per WW-count, <0 for none
1334 short m_nDrawXOfs, m_nDrawYOfs;
1335 short m_nDrawXOfs2, m_nDrawYOfs2;
1337 sal_Unicode m_cSymbol; // symbol to be read now
1339 sal_uInt8 m_nWantedVersion; // originally requested WW-Doc version by Writer
1341 sal_uInt8 m_nSwNumLevel; // level number for outline / enumeration
1342 sal_uInt8 m_nWwNumType; // outline / number / enumeration
1343 const SwNumRule* m_pChosenWW8OutlineStyle; // copied to the "Outline" Chapter Numbering style
1344 sal_uInt8 m_nListLevel;
1346 bool m_bNewDoc; // new document?
1347 bool m_bSkipImages; // skip images for text extraction/indexing
1348 bool m_bReadNoTable; // no tables
1349 bool m_bPgSecBreak; // Page- or Sectionbreak is still to be added
1350 bool m_bSpec; // special char follows in text
1351 bool m_bObj; // Obj in Text
1352 bool m_bTxbxFlySection; // FlyFrame that was inserted as replacement for Winword Textbox
1353 bool m_bHasBorder; // for bundling of the borders
1354 bool m_bSymbol; // e.g. Symbol instead of Times
1355 bool m_bIgnoreText; // e.g. for FieldVanish
1356 int m_nInTable; // are we currently reading a table?
1357 bool m_bWasTabRowEnd; // table : Row End Mark
1358 bool m_bWasTabCellEnd; // table: Cell End Mark
1360 bool m_bAnl; // enumeration in work
1361 // Anl stands for "Autonumber level"
1363 bool m_bHdFtFootnoteEdn; // special text: header/footer/and so on
1364 bool m_bFootnoteEdn; // footnote or endnote
1365 bool m_bIsHeader; // text is read from header ( line height )
1366 bool m_bIsFooter; // text is read from footer ( line height )
1368 bool m_bIsUnicode; // current piece of text is encoded as 2-byte Unicode
1369 // please do NOT handle this as bit field!
1371 bool m_bCpxStyle; // style in the complex part
1372 bool m_bStyNormal; // style with Id 0 is currently read
1373 bool m_bWWBugNormal; // WW-Version with Bug Dya in Style Normal
1374 bool m_bNoAttrImport; // ignore attributes for ignoring styles
1375 bool m_bInHyperlink; // special case for reading 0x01
1376 // see also: SwWW8ImplReader::Read_F_Hyperlink()
1377 bool m_bWasParaEnd;
1379 // useful helper variables
1380 bool m_bVer67; // ( (6 == nVersion) || (7 == nVersion) );
1381 bool m_bVer6; // (6 == nVersion);
1382 bool m_bVer7; // (7 == nVersion);
1383 bool m_bVer8; // (8 == nVersion);
1385 bool m_bEmbeddObj; // EmbeddField is being read
1387 bool m_bCurrentAND_fNumberAcross; // current active Annotated List Descriptor - ROW flag
1389 bool m_bNoLnNumYet; // no Line Numbering has been activated yet (we import
1390 // the very 1st Line Numbering and ignore the rest)
1392 bool m_bFirstPara; // first paragraph?
1393 bool m_bFirstParaOfPage;
1394 bool m_bParaAutoBefore;
1395 bool m_bParaAutoAfter;
1397 bool m_bDropCap;
1398 sal_Int32 m_nDropCap;
1400 bool m_bBidi;
1401 bool m_bReadTable;
1402 // Indicate that currently on loading a TOC, managed by Read_F_TOX() and End_Field()
1403 bool m_bLoadingTOXCache;
1404 int m_nEmbeddedTOXLevel;
1405 // Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field()
1406 bool m_bLoadingTOXHyperlink;
1407 // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
1408 std::optional<SwPaM> m_oPosAfterTOC;
1409 // used for some dropcap tweaking
1410 std::unique_ptr<TextNodeListener> m_xPreviousNode;
1412 std::optional< SwPosition > m_oLastAnchorPos;
1414 bool m_bCareFirstParaEndInToc;
1415 bool m_bCareLastParaEndInToc;
1416 cp_set m_aTOXEndCps;
1418 bool m_bNotifyMacroEventRead;
1419 bool m_bFuzzing;
1421 const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
1423 bool StyleExists(unsigned int nColl) const { return (nColl < m_vColl.size()); }
1424 SwWW8StyInf *GetStyle(sal_uInt16 nColl) const;
1425 void FinalizeTextNode(SwPosition& rPos, bool bAddNew = true);
1427 void Read_HdFt(int nSect, const SwPageDesc *pPrev,
1428 const wwSection &rSection);
1429 void Read_HdFtText(WW8_CP nStartCp, WW8_CP nLen, SwFrameFormat const * pHdFtFormat);
1430 void Read_HdFtTextAsHackedFrame(WW8_CP nStart, WW8_CP nLen,
1431 SwFrameFormat const &rHdFtFormat, sal_uInt16 nPageWidth);
1433 bool isValid_HdFt_CP(WW8_CP nHeaderCP) const;
1435 bool HasOwnHeaderFooter(sal_uInt8 nWhichItems, sal_uInt8 grpfIhdt, int nSect);
1437 void HandleLineNumbering(const wwSection &rSection);
1439 void CopyPageDescHdFt( const SwPageDesc* pOrgPageDesc,
1440 SwPageDesc* pNewPageDesc, sal_uInt8 nCode );
1442 void DeleteStack(std::unique_ptr<SwFltControlStack> prStck);
1443 void DeleteCtrlStack()
1445 DeleteStack(std::move(m_xCtrlStck));
1447 void DeleteRefStacks()
1449 DeleteStack(std::move(m_xReffedStck));
1450 DeleteStack(std::move(m_xReffingStck));
1452 void DeleteAnchorStack()
1454 DeleteStack(std::move(m_xAnchorStck));
1456 void emulateMSWordAddTextToParagraph(const OUString& rAddString);
1457 void simpleAddTextToParagraph(std::u16string_view aAddString);
1458 bool HandlePageBreakChar();
1459 bool ReadChar(tools::Long nPosCp, tools::Long nCpOfs);
1460 bool ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCpOfs);
1461 bool ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, tools::Long nTextEnd, tools::Long nCpOfs);
1462 static bool LangUsesHindiNumbers(LanguageType nLang);
1463 static sal_Unicode TranslateToHindiNumbers(sal_Unicode);
1465 void SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &rSection);
1467 void ProcessCurrentCollChange(WW8PLCFManResult& rRes, bool* pStartAttr,
1468 bool bCallProcessSpecial);
1469 tools::Long ReadTextAttr(WW8_CP& rTextPos, tools::Long nTextEnd, bool& rbStartLine, int nDepthGuard = 0);
1470 void ReadAttrs(WW8_CP& rTextPos, WW8_CP& rNext, tools::Long nTextEnd, bool& rbStartLine);
1471 void CloseAttrEnds();
1472 bool ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType);
1474 void ReadRevMarkAuthorStrTabl( SvStream& rStrm, sal_Int32 nTablePos,
1475 sal_Int32 nTableSiz, SwDoc& rDoc );
1477 void Read_HdFtFootnoteText(const SwNodeIndex* pSttIdx, WW8_CP nStartCp,
1478 WW8_CP nLen, ManTypes nType);
1480 void ImportTox( int nFieldId, const OUString& aStr );
1482 void EndSprm( sal_uInt16 nId );
1483 // #i103711#
1484 // #i105414#
1485 void NewAttr( const SfxPoolItem& rAttr,
1486 const bool bFirstLineOfStSet = false,
1487 const bool bLeftIndentSet = false );
1489 bool GetFontParams(sal_uInt16, FontFamily&, OUString&, FontPitch&,
1490 rtl_TextEncoding&);
1491 bool SetNewFontAttr(sal_uInt16 nFCode, bool bSetEnums, sal_uInt16 nWhich);
1492 void ResetCharSetVars();
1493 void ResetCJKCharSetVars();
1495 const SfxPoolItem* GetFormatAttr( sal_uInt16 nWhich );
1496 template<class T> const T* GetFormatAttr( TypedWhichId<T> nWhich )
1498 return static_cast<const T*>(GetFormatAttr(sal_uInt16(nWhich)));
1501 bool JoinNode(SwPaM &rPam, bool bStealAttr = false);
1503 static bool IsBorder(const WW8_BRCVer9* pbrc, bool bChkBtwn = false);
1505 //Set closest writer border equivalent into rBox from pbrc, optionally
1506 //recording true winword dimensions in pSizeArray. nSetBorders to mark a
1507 //border which has been previously set to a value and for which becoming
1508 //empty is valid. Set bCheBtwn to work with paragraphs that have a special
1509 //between paragraphs border
1511 // Note #i20672# we can't properly support between lines so best to ignore
1512 // them for now
1513 static bool SetBorder(SvxBoxItem& rBox, const WW8_BRCVer9* pbrc,
1514 short *pSizeArray=nullptr, sal_uInt8 nSetBorders=0xFF);
1515 static void GetBorderDistance(const WW8_BRCVer9* pbrc, tools::Rectangle& rInnerDist);
1516 static sal_uInt16 GetParagraphAutoSpace(bool fDontUseHTMLAutoSpacing);
1517 static bool SetShadow(SvxShadowItem& rShadow, const short *pSizeArray,
1518 const WW8_BRCVer9& aRightBrc);
1519 //returns true is a shadow was set
1520 static bool SetFlyBordersShadow(SfxItemSet& rFlySet, const WW8_BRCVer9 *pbrc,
1521 short *SizeArray);
1522 static void SetPageBorder(SwFrameFormat &rFormat, const wwSection &rSection);
1524 static sal_Int32 MatchSdrBoxIntoFlyBoxItem( const Color& rLineColor,
1525 MSO_LineStyle eLineStyle, MSO_LineDashing eDashing, MSO_SPT eShapeType, sal_Int32 &rLineWidth,
1526 SvxBoxItem& rBox );
1527 void MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, SfxItemSet &aFlySet,
1528 MSO_LineStyle eLineStyle, MSO_LineDashing eDashing, MSO_SPT eShapeType, tools::Rectangle &rInnerDist );
1529 static void AdjustLRWrapForWordMargins(const SvxMSDffImportRec &rRecord,
1530 SvxLRSpaceItem &rLR);
1531 static void AdjustULWrapForWordMargins(const SvxMSDffImportRec &rRecord,
1532 SvxULSpaceItem &rUL);
1533 static void MapWrapIntoFlyFormat(const SvxMSDffImportRec& rRecord, SwFrameFormat& rFlyFormat);
1535 void SetAttributesAtGrfNode(const SvxMSDffImportRec& rRecord, const SwFrameFormat& rFlyFormat,
1536 WW8_FSPA const* pF);
1538 bool IsDropCap() const;
1539 bool IsListOrDropcap() const { return (!m_xCurrentItemSet || m_bDropCap); };
1541 //Apo == Absolutely Positioned Object, MSWord's old-style frames
1542 std::unique_ptr<WW8FlyPara> ConstructApo(const ApoTestResults &rApo,
1543 const WW8_TablePos *pTabPos);
1544 bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
1545 void StopApo();
1546 bool TestSameApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
1547 ApoTestResults TestApo(int nCellLevel, bool bTableRowEnd,
1548 const WW8_TablePos *pTabPos);
1549 static void StripNegativeAfterIndent(SwFrameFormat const *pFlyFormat);
1551 void EndSpecial();
1552 bool ProcessSpecial(bool &rbReSync, WW8_CP nStartCp);
1553 sal_uInt16 TabRowSprm(int nLevel) const;
1555 bool ReadGrafFile(OUString& rFileName, std::optional<Graphic>& rpGraphic,
1556 const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pDelIt);
1558 static void ReplaceObj(const SdrObject &rReplaceTextObj,
1559 SdrObject &rSubObj);
1561 SwFlyFrameFormat* MakeGrafNotInContent(const WW8PicDesc& rPD,
1562 const Graphic* pGraph, const OUString& rFileName,
1563 const SfxItemSet& rGrfSet);
1565 SwFrameFormat* MakeGrafInContent(const WW8_PIC& rPic, const WW8PicDesc& rPD,
1566 const Graphic* pGraph, const OUString& rFileName,
1567 const SfxItemSet& rGrfSet);
1569 SwFrameFormat *AddAutoAnchor(SwFrameFormat *pFormat);
1570 SwFrameFormat* ImportGraf1(WW8_PIC const & rPic, SvStream* pSt, sal_uLong nFilePos);
1571 SwFrameFormat* ImportGraf(SdrTextObj const * pTextObj = nullptr, SwFrameFormat const * pFlyFormat = nullptr);
1573 rtl::Reference<SdrObject> ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
1574 const SfxItemSet* pFlySet=nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
1576 SwFrameFormat* ImportOle( const Graphic* = nullptr, const SfxItemSet* pFlySet = nullptr,
1577 const SfxItemSet* pGrfSet = nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
1578 SwFlyFrameFormat* InsertOle(SdrOle2Obj &rObject, const SfxItemSet &rFlySet,
1579 const SfxItemSet *rGrfSet);
1581 bool ImportFormulaControl(WW8FormulaControl &rBox,WW8_CP nStart,
1582 SwWw8ControlType nWhich);
1584 void ImportDop();
1586 //This converts MS Asian Typography information into OOo's
1587 void ImportDopTypography(const WW8DopTypography &rTypo);
1589 ErrCode LoadThroughDecryption(WW8Glossary *pGloss);
1590 ErrCode SetSubStreams(rtl::Reference<SotStorageStream> &rTableStream, rtl::Reference<SotStorageStream> &rDataStream);
1591 ErrCode CoreLoad(WW8Glossary const *pGloss);
1593 void ReadDocVars();
1595 bool StartTable(WW8_CP nStartCp);
1596 bool InEqualApo(int nLvl) const;
1597 bool InLocalApo() const { return InEqualApo(m_nInTable); }
1598 bool InEqualOrHigherApo(int nLvl) const;
1599 void TabCellEnd();
1600 void StopTable();
1601 bool IsInvalidOrToBeMergedTabCell() const;
1603 // Enumerations / lists ( Autonumbered List Data Descriptor )
1604 // list: ANLD ( Autonumbered List Data Descriptor )
1605 // one level: ANLV ( Autonumber Level Descriptor )
1607 // Chg7-8:
1608 // lists are separate structures in WW8 that are handled via the following three tables:
1609 // rglst, hpllfo and hsttbListNames
1610 // the corresponding structures are: LSTF, LVLF, LFO LFOLVL
1612 void SetAnlvStrings(SwNumFormat &rNum, int nLevel, WW8_ANLV const &rAV, const sal_uInt8* pText,
1613 size_t nStart, size_t nElements, bool bOutline);
1614 void SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8 nSwLevel, bool bOutLine);
1615 void SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, sal_uInt8 nSwLevel );
1616 SwNumRule* GetStyRule();
1618 void StartAnl(const sal_uInt8* pSprm13);
1619 void NextAnlLine(const sal_uInt8* pSprm13);
1620 void StopAllAnl(bool bGoBack = true);
1621 void StopAnlToRestart(sal_uInt8 nType, bool bGoBack = true);
1623 // graphics layer
1625 bool ReadGrafStart(void* pData, short nDataSiz, WW8_DPHEAD const * pHd,
1626 SfxAllItemSet &rSet);
1627 rtl::Reference<SdrObject> ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1628 rtl::Reference<SdrObject> ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1629 rtl::Reference<SdrObject> ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1630 rtl::Reference<SdrObject> ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1631 rtl::Reference<SdrObject> ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1632 void InsertTxbxStyAttrs(SfxItemSet& rS, sal_uInt16 nColl, ManTypes eType);
1633 void InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType, bool bONLYnPicLocFc=false);
1635 bool GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, sal_uInt16 nTxBxS,
1636 sal_uInt16 nSequence);
1637 sal_Int32 GetRangeAsDrawingString(OUString& rString, tools::Long StartCp, tools::Long nEndCp, ManTypes eType);
1638 std::optional<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
1639 void InsertTxbxText(SdrTextObj* pTextObj, Size const * pObjSiz,
1640 sal_uInt16 nTxBxS, sal_uInt16 nSequence, tools::Long nPosCp, SwFrameFormat const * pFlyFormat,
1641 bool bMakeSdrGrafObj, bool& rbEraseTextObj,
1642 bool* pbTestTxbxContainsText = nullptr, tools::Long* pnStartCp = nullptr,
1643 tools::Long* pnEndCp = nullptr, bool* pbContainsGraphics = nullptr,
1644 SvxMSDffImportRec const * pRecord = nullptr);
1645 bool TxbxChainContainsRealText( sal_uInt16 nTxBxS,
1646 tools::Long& rStartCp,
1647 tools::Long& rEndCp );
1648 rtl::Reference<SdrObject> ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1649 rtl::Reference<SdrObject> ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1650 rtl::Reference<SdrObject> ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1651 rtl::Reference<SdrObject> ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
1652 void ReadGrafLayer1(WW8PLCFspecial& rPF, tools::Long nGrafAnchorCp);
1653 SdrObject* CreateContactObject(SwFrameFormat* pFlyFormat);
1654 RndStdIds ProcessEscherAlign(SvxMSDffImportRec& rRecord, WW8_FSPA& rFSPA, SfxItemSet& rFlySet);
1655 bool MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
1656 sal_Int16 eHoriOri, sal_Int16 eHoriRel);
1657 SwFrameFormat* Read_GrafLayer( tools::Long nGrafAnchorCp );
1658 SwFlyFrameFormat* ImportReplaceableDrawables(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
1659 SvxMSDffImportRec& rRecord, WW8_FSPA& rF,
1660 SfxItemSet& rFlySet);
1661 SwFlyFrameFormat* ConvertDrawTextToFly(rtl::Reference<SdrObject>& rpObject, rtl::Reference<SdrObject>& rpOurNewObject,
1662 const SvxMSDffImportRec& rRecord, RndStdIds eAnchor,
1663 const WW8_FSPA& rF, SfxItemSet& rFlySet);
1664 SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec& rRecord, tools::Long nGrafAnchorCp,
1665 SwFrameFormat* pRetFrameFormat);
1667 void GraphicCtor();
1668 void GraphicDtor();
1670 // other stuff
1671 OUString GetFieldResult( WW8FieldDesc const * pF );
1672 void MakeTagString( OUString& rStr, const OUString& rOrg );
1673 void UpdateFields();
1674 OUString ConvertFFileName(const OUString& rRaw);
1675 WW8_CP Read_F_Tag(WW8FieldDesc* pF);
1676 void InsertTagField( const sal_uInt16 nId, const OUString& rTagText );
1677 tools::Long ImportExtSprm(WW8PLCFManResult* pRes);
1678 void EndExtSprm(sal_uInt16 nSprmId);
1679 void ReadDocInfo();
1681 // Ver8 lists
1683 void RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO, sal_uInt8 nCurrentLevel,
1684 const bool bSetAttr = true);
1686 void RegisterNumFormatOnStyle(sal_uInt16 nStyle);
1687 void SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
1688 sal_uInt8 nCurrentLevel);
1689 void RegisterNumFormat(sal_uInt16 nCurrentLFO, sal_uInt8 nCurrentLevel);
1691 // to be replaced by calls in the appropriate extended SvxMSDffManager
1693 const OUString* GetAnnotationAuthor(sal_uInt16 nIdx);
1695 void GetSmartTagInfo(SwFltRDFMark& rMark);
1697 // interfaces for the toggle attributes
1698 void SetToggleAttr(sal_uInt8 nAttrId, bool bOn);
1699 void SetToggleBiDiAttr(sal_uInt8 nAttrId, bool bOn);
1700 void ChkToggleAttr_( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask );
1702 void ChkToggleAttr( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask )
1704 if( nOldStyle81Mask != nNewStyle81Mask &&
1705 m_xCtrlStck->GetToggleAttrFlags() )
1706 ChkToggleAttr_( nOldStyle81Mask, nNewStyle81Mask );
1709 void ChkToggleBiDiAttr_( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask );
1711 void ChkToggleBiDiAttr( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask )
1713 if( nOldStyle81Mask != nNewStyle81Mask &&
1714 m_xCtrlStck->GetToggleBiDiAttrFlags() )
1715 ChkToggleBiDiAttr_( nOldStyle81Mask, nNewStyle81Mask );
1718 void PopTableDesc();
1719 void MoveInsideFly(const SwFrameFormat *pFlyFormat);
1720 SwTwips MoveOutsideFly(SwFrameFormat *pFlyFormat, const SwPosition &rPos,
1721 bool bTableJoin = true);
1723 void SetOutlineStyles();
1725 bool SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper);
1726 bool SetUpperSpacing(SwPaM &pMyPam, int nSpace);
1727 bool SetLowerSpacing(SwPaM &rMyPam, int nSpace);
1729 bool IsInlineEscherHack() const
1730 { return !m_aFieldStack.empty() && m_aFieldStack.back().mnFieldId == 95; };
1732 void StoreMacroCmds();
1734 // #i84783#
1735 // determine object attribute "Layout in Table Cell"
1736 bool IsObjectLayoutInTableCell(const sal_uInt32 nGroupShapeBooleanProperties) const;
1737 void ReadGlobalTemplateSettings( std::u16string_view sCreatedFrom, const css::uno::Reference< css::container::XNameContainer >& xPrjNameMap );
1738 SwWW8ImplReader(const SwWW8ImplReader &) = delete;
1739 SwWW8ImplReader& operator=(const SwWW8ImplReader&) = delete;
1740 public: // really private, but can only be done public
1741 ~SwWW8ImplReader();
1742 sal_uInt16 GetToggleAttrFlags() const;
1743 sal_uInt16 GetToggleBiDiAttrFlags() const;
1744 void SetToggleAttrFlags(sal_uInt16 nFlags);
1745 void SetToggleBiDiAttrFlags(sal_uInt16 nFlags);
1747 tools::Long Read_Footnote(WW8PLCFManResult* pRes);
1748 sal_uInt16 End_Footnote();
1749 tools::Long Read_Field(WW8PLCFManResult* pRes);
1750 sal_uInt16 End_Field();
1751 tools::Long Read_Book(WW8PLCFManResult*);
1752 tools::Long Read_And(WW8PLCFManResult* pRes);
1753 tools::Long Read_AtnBook(WW8PLCFManResult*);
1754 tools::Long Read_FactoidBook(WW8PLCFManResult*);
1756 // attributes
1758 void Read_Special(sal_uInt16, const sal_uInt8*, short nLen);
1759 void Read_Obj(sal_uInt16, const sal_uInt8*, short nLen);
1760 void Read_PicLoc(sal_uInt16, const sal_uInt8* pData, short nLen );
1761 void Read_BoldUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
1762 void Read_Bidi(sal_uInt16 nId, const sal_uInt8*, short nLen);
1763 void Read_BoldBiDiUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
1764 void Read_AmbiguousSPRM(sal_uInt16 nId, const sal_uInt8*, short nLen);
1765 void Read_SubSuper( sal_uInt16, const sal_uInt8*, short nLen );
1766 bool ConvertSubToGraphicPlacement();
1767 static SwFrameFormat *ContainsSingleInlineGraphic(const SwPaM &rRegion);
1768 void Read_SubSuperProp( sal_uInt16, const sal_uInt8*, short nLen );
1769 void Read_Underline( sal_uInt16, const sal_uInt8*, short nLen );
1770 void Read_TextColor( sal_uInt16, const sal_uInt8*, short nLen );
1771 void openFont(sal_uInt16 nFCode, sal_uInt16 nId);
1772 void closeFont(sal_uInt16 nId);
1773 void Read_FontCode( sal_uInt16, const sal_uInt8*, short nLen );
1774 void Read_FontSize( sal_uInt16, const sal_uInt8*, short nLen );
1775 void Read_CharSet(sal_uInt16 , const sal_uInt8* pData, short nLen);
1776 void Read_Language( sal_uInt16, const sal_uInt8*, short nLen );
1777 void Read_CColl( sal_uInt16, const sal_uInt8*, short nLen );
1778 void Read_Kern( sal_uInt16, const sal_uInt8* pData, short nLen );
1779 void Read_FontKern( sal_uInt16, const sal_uInt8* pData, short nLen );
1780 void Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short nLen );
1781 void Read_ScaleWidth( sal_uInt16, const sal_uInt8* pData, short nLen );
1782 void Read_Relief( sal_uInt16, const sal_uInt8* pData, short nLen);
1783 void Read_TextAnim( sal_uInt16, const sal_uInt8* pData, short nLen);
1785 void Read_NoLineNumb( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1787 void Read_LR( sal_uInt16 nId, const sal_uInt8*, short nLen );
1788 void Read_UL( sal_uInt16 nId, const sal_uInt8*, short nLen );
1789 void Read_ParaAutoBefore(sal_uInt16 , const sal_uInt8 *pData, short nLen);
1790 void Read_ParaAutoAfter(sal_uInt16 , const sal_uInt8 *pData, short nLen);
1791 void Read_ParaContextualSpacing( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1792 void Read_LineBreakClear(sal_uInt16 nId, const sal_uInt8* pData, short nLen);
1793 void Read_LineSpace( sal_uInt16, const sal_uInt8*, short nLen );
1795 void SetRelativeJustify( bool bRel );
1796 bool IsRelativeJustify();
1797 bool IsRelativeJustify(sal_uInt16 nColl, o3tl::sorted_vector<sal_uInt16>& rVisitedStyles);
1798 void Read_Justify(sal_uInt16, const sal_uInt8*, short nLen);
1800 void Read_IdctHint(sal_uInt16, const sal_uInt8*, short nLen);
1801 bool IsRightToLeft();
1802 void Read_RTLJustify(sal_uInt16, const sal_uInt8*, short nLen);
1803 void Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, short nLen );
1804 void Read_WidowControl( sal_uInt16, const sal_uInt8* pData, short nLen );
1805 void Read_AlignFont( sal_uInt16, const sal_uInt8* pData, short nLen );
1806 void Read_UsePgsuSettings( sal_uInt16, const sal_uInt8* pData, short nLen );
1807 void Read_KeepLines( sal_uInt16, const sal_uInt8* pData, short nLen );
1808 void Read_KeepParas( sal_uInt16, const sal_uInt8* pData, short nLen );
1809 void Read_BreakBefore( sal_uInt16, const sal_uInt8* pData, short nLen );
1810 void Read_ApoPPC(sal_uInt16, const sal_uInt8* pData, short);
1812 void Read_BoolItem( sal_uInt16 nId, const sal_uInt8*, short nLen );
1814 void Read_Border( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1815 void Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1816 void Read_Tab( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1817 void Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen);
1818 void Read_FieldVanish( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1820 // Revision Marks ( == Redlining )
1822 // insert or delete content (change char attributes resp.)
1823 void Read_CRevisionMark(RedlineType eType, const sal_uInt8* pData, short nLen);
1824 // insert new content
1825 void Read_CFRMark(sal_uInt16 , const sal_uInt8* pData, short nLen);
1826 // delete old content
1827 void Read_CFRMarkDel(sal_uInt16 , const sal_uInt8* pData, short nLen);
1828 // change properties of content (e.g. char formatting)
1829 void Read_CPropRMark(sal_uInt16 , const sal_uInt8* pData, short nLen); // complex!
1831 void Read_TabRowEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
1832 void Read_TabCellEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
1833 static bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
1834 void Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen );
1835 void Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short nLen );
1836 void Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, short nLen );
1838 // outline level Ver8
1839 void Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLen);
1841 void Read_OLST( sal_uInt16, const sal_uInt8* pData, short nLen );
1843 void Read_CharShadow( sal_uInt16, const sal_uInt8* pData, short nLen );
1844 void Read_CharHighlight( sal_uInt16, const sal_uInt8* pData, short nLen );
1845 // Ver8-Listen
1847 void Read_ListLevel( sal_uInt16 nId, const sal_uInt8* pData, short nLen);
1850 * read and interpret the sprmPIlfo used to determine which list
1851 * contains the paragraph.
1852 * @param nId unused (sprm value, 0x460b for sprmPIlfo).
1853 * @param[in] pData operand.
1854 * @param[in] nLen size of the operand (pData) in byte, should be 2.
1855 * -1 to indicate the actual level is finished.
1857 void Read_LFOPosition( sal_uInt16 nId, const sal_uInt8* pData, short nLen);
1858 bool SetTextFormatCollAndListLevel(const SwPaM& rRg, SwWW8StyInf& rStyleInfo);
1860 void Read_StyleCode(sal_uInt16, const sal_uInt8* pData, short nLen);
1861 void Read_Majority(sal_uInt16, const sal_uInt8* , short );
1862 void Read_DoubleLine_Rotate( sal_uInt16, const sal_uInt8* pDATA, short nLen);
1864 void Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1865 void Read_TextBackColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1866 void Read_ParaBackColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1867 void Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nLen);
1868 static Color ExtractColour(const sal_uInt8* &rpData, bool bVer67);
1870 void Read_TextVerticalAdjustment(sal_uInt16, const sal_uInt8* pData, short nLen);
1871 void Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1872 tools::Long MapBookmarkVariables(const WW8FieldDesc* pF, OUString &rOrigName,
1873 const OUString &rData);
1874 OUString GetMappedBookmark(std::u16string_view rOrigName);
1876 // fields
1877 eF_ResT Read_F_Input(WW8FieldDesc*, OUString& rStr);
1878 eF_ResT Read_F_InputVar(WW8FieldDesc*, OUString& rStr);
1879 eF_ResT Read_F_ANumber( WW8FieldDesc*, OUString& );
1880 eF_ResT Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr );
1881 eF_ResT Read_F_Author( WW8FieldDesc*, OUString& );
1882 eF_ResT Read_F_TemplName( WW8FieldDesc*, OUString& );
1883 SvNumFormatType GetTimeDatePara(std::u16string_view aStr, sal_uInt32& rFormat, LanguageType &rLang,
1884 int nWhichDefault, bool bHijri = false);
1885 bool ForceFieldLanguage(SwField &rField, LanguageType nLang);
1886 eF_ResT Read_F_DateTime( WW8FieldDesc*, OUString& rStr );
1887 eF_ResT Read_F_FileName( WW8FieldDesc*, OUString& rStr);
1888 eF_ResT Read_F_Num( WW8FieldDesc* pF, OUString& );
1889 eF_ResT Read_F_CurPage( WW8FieldDesc*, OUString& );
1890 eF_ResT Read_F_Ref( WW8FieldDesc* pF, OUString& );
1892 eF_ResT Read_F_Set( WW8FieldDesc*, OUString& rStr );
1893 eF_ResT Read_F_PgRef( WW8FieldDesc*, OUString& rStr );
1894 eF_ResT Read_F_NoteReference( WW8FieldDesc* pF, OUString& rStr );
1896 eF_ResT Read_F_Tox( WW8FieldDesc* pF, OUString& rStr );
1897 eF_ResT Read_F_Symbol( WW8FieldDesc*, OUString& rStr );
1898 eF_ResT Read_F_Embedd( WW8FieldDesc*, OUString& rStr );
1899 eF_ResT Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr);
1900 eF_ResT Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr );
1901 eF_ResT Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr);
1902 css::awt::Size MiserableDropDownFormHack(const OUString &rString,
1903 css::uno::Reference<css::beans::XPropertySet> const & rPropSet);
1905 eF_ResT Read_F_Macro( WW8FieldDesc*, OUString& rStr);
1906 eF_ResT Read_F_DBField( WW8FieldDesc*, OUString& rStr );
1907 eF_ResT Read_F_DBNext( WW8FieldDesc*, OUString& );
1908 eF_ResT Read_F_DBNum( WW8FieldDesc*, OUString& );
1909 eF_ResT Read_F_Equation( WW8FieldDesc*, OUString& );
1910 void Read_SubF_Ruby( msfilter::util::WW8ReadFieldParams& rReadParam);
1911 eF_ResT Read_F_IncludePicture( WW8FieldDesc*, OUString& rStr );
1912 eF_ResT Read_F_IncludeText( WW8FieldDesc*, OUString& rStr );
1913 eF_ResT Read_F_Seq( WW8FieldDesc*, OUString& rStr );
1914 /// Reads a STYLEREF field.
1915 eF_ResT Read_F_Styleref(WW8FieldDesc*, OUString& rStr);
1917 eF_ResT Read_F_OCX(WW8FieldDesc*, OUString&);
1918 eF_ResT Read_F_Hyperlink(WW8FieldDesc*, OUString& rStr);
1919 eF_ResT Read_F_Shape(WW8FieldDesc* pF, OUString& rStr);
1920 eF_ResT Read_F_HTMLControl( WW8FieldDesc* pF, OUString& rStr);
1922 short ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId = 0);
1924 bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP &rStartCp, int nLevel) const;
1926 const WW8Fib& GetFib() const { return *m_xWwFib; }
1927 SwDoc& GetDoc() const { return m_rDoc; }
1928 sal_uInt16 GetCurrentColl() const { return m_nCurrentColl; }
1929 void SetNCurrentColl( sal_uInt16 nColl ) { m_nCurrentColl = nColl; }
1930 std::unique_ptr<SfxItemSet> SetCurrentItemSet(std::unique_ptr<SfxItemSet> pItemSet);
1931 sal_uInt16 StyleUsingLFO( sal_uInt16 nLFOIndex ) const ;
1932 const SwFormat* GetStyleWithOrgWWName( std::u16string_view rName ) const ;
1934 static bool GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc);
1935 SAL_WARN_UNUSED_RESULT static bool PicRead(SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
1936 static bool ImportOleWMF(const rtl::Reference<SotStorage>& xSrc1, GDIMetaFile& rWMF, tools::Long& rX,
1937 tools::Long& rY);
1938 static Color GetCol(sal_uInt8 nIco);
1940 SwWW8ImplReader( sal_uInt8 nVersionPara, SotStorage* pStorage, SvStream* pSt,
1941 SwDoc& rD, OUString aBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos );
1943 const OUString& GetBaseURL() const { return m_sBaseURL; }
1944 // load a complete doc file
1945 ErrCode LoadDoc(WW8Glossary *pGloss=nullptr);
1946 rtl_TextEncoding GetCurrentCharSet();
1947 rtl_TextEncoding GetCurrentCJKCharSet();
1948 rtl_TextEncoding GetCharSetFromLanguage();
1949 rtl_TextEncoding GetCJKCharSetFromLanguage();
1951 void PostProcessAttrs();
1952 void ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocShell, struct HyperLinksTable& hlStr);
1953 void NotifyMacroEventRead();
1956 bool CanUseRemoteLink(const OUString &rGrfName);
1957 void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat);
1958 void SetStyleIndent(SwWW8StyInf &rStyleInfo, const SwNumFormat &rFormat);
1959 // #i103711#
1960 // #i105414#
1961 void SyncIndentWithList( SvxFirstLineIndentItem & rFirstLine,
1962 SvxTextLeftMarginItem & rLeftMargin,
1963 const SwNumFormat &rFormat,
1964 const bool bFirstLineOfStSet,
1965 const bool bLeftIndentSet );
1966 tools::Long GetListFirstLineIndent(const SwNumFormat &rFormat);
1967 OUString BookmarkToWriter(std::u16string_view rBookmark);
1968 bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
1969 sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
1970 SwTwips nPageRight, SwTwips nPageSize);
1971 void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord,
1972 SfxItemSet &rFlySet);
1973 #endif
1975 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */