nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / filter / ww8 / ww8par.hxx
blob9626adf3767f3ab6cddd99cd3a4bd94541030879
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 <fltshell.hxx>
29 #include <svx/svdobj.hxx>
31 #include <vector>
32 #include <stack>
33 #include <string_view>
34 #include <deque>
35 #include <map>
36 #include <utility>
37 #include <memory>
39 #include "ww8struc.hxx"
40 #include "ww8scan.hxx"
41 #include "ww8glsy.hxx"
42 #include "ww8graf.hxx"
43 #include "wrtww8.hxx"
44 #include <msfilter.hxx>
45 #include <xmloff/odffields.hxx>
46 #include <IMark.hxx>
48 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
49 #include <swtypes.hxx>
50 #include <fmtfsize.hxx>
51 #include <fmtornt.hxx>
52 #include <fmtsrnd.hxx>
53 #include <ndtxt.hxx>
54 #include <editeng/lrspitem.hxx>
55 #include <o3tl/deleter.hxx>
56 #include <o3tl/sorted_vector.hxx>
57 #include <oox/ole/olehelper.hxx>
59 #define SW_UD_IMAPDATA 2
61 class SwDoc;
62 class SwPaM;
63 class SfxPoolItem;
64 class SwTextFormatColl;
65 class SwPageDesc;
66 class SvxBoxItem;
67 class SwFormat;
68 class SwNodeIndex;
69 class SwFlyFrameFormat;
70 class SwAttrSet;
71 class SwNumRule;
72 class SwFrameFormat;
73 class Writer;
74 class SwFormatField;
75 class WW8Fib;
76 class WW8PLCFMan;
77 struct WW8PLCFManResult;
78 class WW8RStyle;
79 class WW8PLCF_HdFt;
80 class WW8ScannerBase;
81 struct WW8FlyPara;
82 struct WW8SwFlyPara;
83 struct WW8_PIC;
84 class WW8TabDesc;
85 struct WW8_SHD;
86 struct WW8_OLST;
87 class SwNumFormat;
88 struct WW8_ANLD;
89 struct WW8_ANLV;
90 struct WW8_DO;
91 struct WW8_DPHEAD;
92 struct WW8_FSPA;
93 class SdrModel;
94 class SdrPage;
95 class SdrObject;
96 class SdrTextObj;
97 class SdrUnoObj;
98 class Size;
99 class EditEngine;
100 struct SwPosition;
101 class WW8ReaderSave;
102 struct WW8PicDesc;
103 class Graphic;
104 class SwFieldType;
105 class SotStorage;
106 class SwAttrSet;
107 class GDIMetaFile;
108 struct ESelection;
109 class SfxItemSet;
110 class OutlinerParaObject;
112 namespace com::sun::star{
113 namespace beans{ class XPropertySet;}
114 namespace form { class XFormComponent;}
115 namespace drawing{class XShape;}
116 namespace lang{class XMultiServiceFactory;}
119 // defines only for the WW8-variable of the INI file
120 #define WW8FL_NO_STYLES 2
121 #define WW8FL_NO_GRAF 0x80
123 #define WW8FL_NO_OUTLINE 0x1000
124 #define WW8FL_NO_IMPLPASP 0x4000 // no implicit para space
125 #define WW8FL_NO_GRAFLAYER 0x8000
127 // Add-on-filter-flags, valid from Winword 8 on
128 #define WW8FL_NO_FLY_FOR_TXBX 1
130 // List-Manager (from Ver8 on)
132 struct WW8LFOInfo;
134 class WW8Reader : public StgReader
136 std::shared_ptr<SvStream> mDecodedStream;
137 virtual ErrCode Read(SwDoc &, const OUString& rBaseURL, SwPaM &, const OUString &) override;
138 ErrCode OpenMainStream( tools::SvRef<SotStorageStream>& rRef, sal_uInt16& rBuffSize );
139 ErrCode DecryptDRMPackage();
140 public:
141 WW8Reader() {}
142 virtual SwReaderType GetReaderType() override;
144 virtual bool HasGlossaries() const override;
145 virtual bool ReadGlossaries( SwTextBlocks&, bool bSaveRelFiles ) const override;
148 class SwWW8ImplReader;
149 struct WW8LSTInfo;
150 class WW8ListManager
152 public:
153 WW8ListManager(SvStream& rSt_, SwWW8ImplReader& rReader_);
154 //Min and Max possible List Levels in Word
155 enum ListLevel {nMinLevel=1, nMaxLevel=9};
156 //the rParaSprms returns back the original word paragraph indent
157 //sprms which were attached to the original numbering format
158 SwNumRule* GetNumRuleForActivation(sal_uInt16 nLFOPosition, const sal_uInt8 nLevel,
159 std::vector<sal_uInt8> &rParaSprms, SwTextNode *pNode=nullptr);
160 SwNumRule* CreateNextRule(bool bSimple);
161 ~WW8ListManager() COVERITY_NOEXCEPT_FALSE;
162 SwNumRule* GetNumRule(size_t i);
163 size_t GetWW8LSTInfoNum() const{return maLSTInfos.size();}
164 static SvxNumType GetSvxNumTypeFromMSONFC(sal_uInt16 nMSONFC);
166 private:
167 wwSprmParser maSprmParser;
168 SwWW8ImplReader& rReader;
169 SwDoc& rDoc;
170 const WW8Fib& rFib;
171 SvStream& rSt;
172 std::vector<std::unique_ptr<WW8LSTInfo>> maLSTInfos;
173 std::vector<std::unique_ptr<WW8LFOInfo>> m_LFOInfos;// D. from PLF LFO, sorted exactly like in the WW8 Stream
174 sal_uInt16 nUniqueList; // current number for creating unique list names
175 SprmResult GrpprlHasSprm(sal_uInt16 nId, sal_uInt8& rSprms, sal_uInt8 nLen);
176 WW8LSTInfo* GetLSTByListId( sal_uInt32 nIdLst ) const;
177 //the rParaSprms returns back the original word paragraph indent
178 //sprms which are attached to this numbering level
179 bool ReadLVL(SwNumFormat& rNumFormat, std::unique_ptr<SfxItemSet>& rpItemSet, sal_uInt16 nLevelStyle,
180 bool bSetStartNo, sal_uInt16 nLevel, ww::bytes &rParaSprms);
182 // character attributes from GrpprlChpx
183 typedef std::unique_ptr<SfxItemSet> WW8aISet[nMaxLevel];
184 // character style pointer
185 typedef SwCharFormat* WW8aCFormat[nMaxLevel];
187 void AdjustLVL(sal_uInt8 nLevel, SwNumRule& rNumRule, WW8aISet const & rListItemSet,
188 WW8aCFormat& aCharFormat, bool& bNewCharFormatCreated,
189 const OUString& aPrefix = OUString());
191 WW8ListManager(const WW8ListManager&) = delete;
192 WW8ListManager& operator=(const WW8ListManager&) = delete;
193 sal_uInt16 nLastLFOPosition;
196 struct WW8FlyPara
197 { // WinWord-attributes
198 // Attention: *DO NOT* reorder, since parts will be
199 // compared using memcmp
200 bool bVer67;
201 sal_Int16 nSp26, nSp27; // raw position
202 sal_Int16 nSp45, nSp28; // width / height
203 sal_Int16 nLeMgn, nRiMgn, nUpMgn, nLoMgn; // borders
204 sal_uInt8 nSp29; // raw binding + alignment
205 sal_uInt8 nSp37; // Wrap-Mode ( 1 / 2; 0 = no Apo ? )
206 WW8_BRCVer9_5 brc; // borders Top, Left, Bottom, Right, Between
207 bool bBorderLines; // border lines
208 bool bGrafApo; // true: this frame is only used to position
209 // the contained graphics *not* as a character
210 bool mbVertSet; // true if vertical positioning has been set
212 WW8FlyPara(bool bIsVer67, const WW8FlyPara* pSrc = nullptr);
213 bool operator==(const WW8FlyPara& rSrc) const;
214 void Read(sal_uInt8 nSprm29, WW8PLCFx_Cp_FKP* pPap);
215 void ReadFull(sal_uInt8 nSprm29, SwWW8ImplReader* pIo);
216 void Read(sal_uInt8 nSprm29, WW8RStyle const * pStyle);
217 void ApplyTabPos(const WW8_TablePos *pTabPos);
218 bool IsEmpty() const;
221 class SwWW8StyInf
223 OUString m_sWWStyleName;
224 sal_uInt16 m_nWWStyleId;
225 public:
226 rtl_TextEncoding m_eLTRFontSrcCharSet; // rtl_TextEncoding for the font
227 rtl_TextEncoding m_eRTLFontSrcCharSet; // rtl_TextEncoding for the font
228 rtl_TextEncoding m_eCJKFontSrcCharSet; // rtl_TextEncoding for the font
229 SwFormat* m_pFormat;
230 std::shared_ptr<WW8FlyPara> m_xWWFly;
231 SwNumRule* m_pOutlineNumrule;
232 tools::Long m_nFilePos;
233 sal_uInt16 m_nBase;
234 sal_uInt16 m_nFollow;
235 sal_uInt16 m_nLFOIndex;
236 sal_uInt8 m_nListLevel;
238 // WW8 outline level is zero-based:
239 // 0: outline level 1
240 // 1: outline level 2
241 // ...
242 // 8: outline level 9
243 // 9: body text
244 sal_uInt8 mnWW8OutlineLevel;
246 sal_uInt16 m_n81Flags; // for bold, italic, ...
247 sal_uInt16 m_n81BiDiFlags; // for bold, italic, ...
248 std::shared_ptr<SvxLRSpaceItem> maWordLR;
249 bool m_bValid; // empty of valid
250 bool m_bImported; // for recursive imports
251 bool m_bColl; // true-> pFormat is SwTextFormatColl
252 bool m_bImportSkipped; // only true if !bNewDoc && existing style
253 bool m_bHasStyNumRule; // true-> named NumRule in style
254 bool m_bHasBrokenWW6List; // true-> WW8+ style has a WW7- list
255 bool m_bListRelevantIndentSet; //true if this style's indent has
256 //been explicitly set, it's set to the value
257 //of pFormat->GetItemState(RES_LR_SPACE, false)
258 //if it was possible to get the ItemState
259 //for L of the LR space independently
260 bool m_bParaAutoBefore; // For Auto spacing before a paragraph
261 bool m_bParaAutoAfter; // For Auto Spacing after a paragraph
262 sal_Int16 m_nRelativeJustify;
264 SwWW8StyInf() :
265 m_sWWStyleName( OUString() ),
266 m_nWWStyleId( 0 ),
267 m_eLTRFontSrcCharSet(0),
268 m_eRTLFontSrcCharSet(0),
269 m_eCJKFontSrcCharSet(0),
270 m_pFormat( nullptr ),
271 m_pOutlineNumrule( nullptr ),
272 m_nFilePos( 0 ),
273 m_nBase( 0 ),
274 m_nFollow( 0 ),
275 m_nLFOIndex( USHRT_MAX ),
276 m_nListLevel(WW8ListManager::nMaxLevel),
277 mnWW8OutlineLevel( MAXLEVEL ),
278 m_n81Flags( 0 ),
279 m_n81BiDiFlags(0),
280 maWordLR(std::make_shared<SvxLRSpaceItem>(RES_LR_SPACE)),
281 m_bValid(false),
282 m_bImported(false),
283 m_bColl(false),
284 m_bImportSkipped(false),
285 m_bHasStyNumRule(false),
286 m_bHasBrokenWW6List(false),
287 m_bListRelevantIndentSet(false),
288 m_bParaAutoBefore(false),
289 m_bParaAutoAfter(false),
290 m_nRelativeJustify(-1)
294 void SetOrgWWIdent( const OUString& rName, const sal_uInt16 nId )
296 m_sWWStyleName = rName;
297 m_nWWStyleId = nId;
299 // apply default WW8 outline level to WW8 Built-in Heading styles
300 if (IsWW8BuiltInHeadingStyle())
302 mnWW8OutlineLevel = m_nWWStyleId - 1;
306 const OUString& GetOrgWWName() const
308 return m_sWWStyleName;
311 bool HasWW8OutlineLevel() const
313 return (m_pFormat != nullptr && (MAXLEVEL > mnWW8OutlineLevel));
316 bool IsOutlineNumbered() const
318 return m_pOutlineNumrule && HasWW8OutlineLevel();
321 const SwNumRule* GetOutlineNumrule() const
323 return m_pOutlineNumrule;
325 rtl_TextEncoding GetCharSet() const;
326 rtl_TextEncoding GetCJKCharSet() const;
328 sal_uInt16 GetWWStyleId() const
330 return m_nWWStyleId;
333 bool IsWW8BuiltInHeadingStyle() const
335 return GetWWStyleId() >= 1 && GetWWStyleId() <= 9;
338 bool IsWW8BuiltInDefaultStyle() const
340 return GetWWStyleId() == 0;
343 static sal_uInt8
344 WW8OutlineLevelToOutlinelevel(const sal_uInt8 nWW8OutlineLevel)
346 if (nWW8OutlineLevel < MAXLEVEL)
348 if (nWW8OutlineLevel == 9)
350 return 0; // no outline level --> body text
352 else
354 return nWW8OutlineLevel + 1; // outline level 1..9
358 return 0;
362 // Stack
364 class SwWW8FltControlStack : public SwFltControlStack
366 private:
367 SwWW8ImplReader& rReader;
368 std::unique_ptr<SfxItemSet> m_xScratchSet;
369 sal_uInt16 nToggleAttrFlags;
370 sal_uInt16 nToggleBiDiAttrFlags;
371 SwWW8FltControlStack(const SwWW8FltControlStack&) = delete;
372 SwWW8FltControlStack& operator=(const SwWW8FltControlStack&) = delete;
373 const SwNumFormat* GetNumFormatFromStack(const SwPosition &rPos,
374 const SwTextNode &rTextNode);
375 protected:
376 virtual void SetAttrInDoc(const SwPosition& rTmpPos,
377 SwFltStackEntry& rEntry) override;
379 virtual sal_Int32 GetCurrAttrCP() const override;
380 virtual bool IsParaEndInCPs(sal_Int32 nStart, sal_Int32 nEnd, bool bSdOD) const override;
381 //Clear the para end position recorded in reader intermittently for the least impact on loading performance
382 virtual void ClearParaEndPosition() override;
383 virtual bool CheckSdOD(sal_Int32 nStart,sal_Int32 nEnd) override;
385 public:
386 SwWW8FltControlStack(SwDoc& rDo, sal_uLong nFieldFl, SwWW8ImplReader& rReader_ )
387 : SwFltControlStack( rDo, nFieldFl ), rReader( rReader_ ),
388 nToggleAttrFlags(0), nToggleBiDiAttrFlags(0)
391 void NewAttr(const SwPosition& rPos, const SfxPoolItem& rAttr);
393 virtual SwFltStackEntry* SetAttr(const SwPosition& rPos, sal_uInt16 nAttrId, bool bTstEnd=true, tools::Long nHand=LONG_MAX, bool consumedByField=false) override;
395 void SetToggleAttr(sal_uInt8 nId, bool bOn)
397 if( bOn )
398 nToggleAttrFlags |= (1 << nId);
399 else
400 nToggleAttrFlags &= ~(1 << nId);
403 sal_uInt16 GetToggleAttrFlags() const { return nToggleAttrFlags; }
405 void SetToggleBiDiAttr(sal_uInt8 nId, bool bOn)
407 if( bOn )
408 nToggleBiDiAttrFlags |= (1 << nId);
409 else
410 nToggleBiDiAttrFlags &= ~(1 << nId);
413 sal_uInt16 GetToggleBiDiAttrFlags() const { return nToggleBiDiAttrFlags; }
414 void SetToggleAttrFlags(sal_uInt16 nFlags) { nToggleAttrFlags = nFlags; }
415 void SetToggleBiDiAttrFlags(sal_uInt16 nFlags) {nToggleBiDiAttrFlags = nFlags;}
417 const SfxPoolItem* GetFormatAttr(const SwPosition& rPos, sal_uInt16 nWhich);
418 template<class T> const T* GetFormatAttr( const SwPosition& rPos, TypedWhichId<T> nWhich )
420 return static_cast<const T*>(GetFormatAttr(rPos, sal_uInt16(nWhich)));
422 const SfxPoolItem* GetStackAttr(const SwPosition& rPos, sal_uInt16 nWhich);
425 //The only thing this is for is RES_FLTR_ANCHOR, anything else is an error.
426 //For graphics whose anchoring position would otherwise be automatically moved
427 //along by the insertion of text.
428 class SwWW8FltAnchorStack : public SwFltControlStack
430 public:
431 SwWW8FltAnchorStack(SwDoc& rDo, sal_uLong nFieldFl)
432 : SwFltControlStack( rDo, nFieldFl ) {}
433 void AddAnchor(const SwPosition& rPos,SwFrameFormat *pFormat);
434 void Flush();
435 private:
436 SwWW8FltAnchorStack(const SwWW8FltAnchorStack&) = delete;
437 SwWW8FltAnchorStack& operator=(const SwWW8FltAnchorStack&) = delete;
441 namespace SwWW8
443 struct ltstr
445 bool operator()(const OUString &r1, std::u16string_view r2) const
447 return r1.compareToIgnoreAsciiCase(r2)<0;
451 struct ltnode
453 bool operator()(const SwTextNode *r1, const SwTextNode *r2) const
455 return r1->GetIndex() < r2->GetIndex();
460 class SwWW8ReferencedFltEndStack : public SwFltEndStack
462 public:
463 SwWW8ReferencedFltEndStack( SwDoc& rDo, sal_uLong nFieldFl )
464 : SwFltEndStack( rDo, nFieldFl )
465 , aReferencedTOCBookmarks()
468 // Keep track of referenced TOC bookmarks in order to suppress the import
469 // of unreferenced ones.
470 std::set<OUString, SwWW8::ltstr> aReferencedTOCBookmarks;
471 protected:
472 virtual void SetAttrInDoc( const SwPosition& rTmpPos,
473 SwFltStackEntry& rEntry ) override;
476 class SwWW8FltRefStack final : public SwFltEndStack
478 public:
479 SwWW8FltRefStack(SwDoc& rDo, sal_uLong nFieldFl)
480 : SwFltEndStack( rDo, nFieldFl )
481 , aFieldVarNames()
483 bool IsFootnoteEdnBkmField(const SwFormatField& rFormatField, sal_uInt16& rBkmNo);
485 //Keep track of variable names created with fields, and the bookmark
486 //mapped to their position, hopefully the same, but very possibly
487 //an additional pseudo bookmark
488 std::map<OUString, OUString, SwWW8::ltstr> aFieldVarNames;
489 private:
490 SwFltStackEntry *RefToVar(const SwField* pField,SwFltStackEntry& rEntry);
491 virtual void SetAttrInDoc(const SwPosition& rTmpPos,
492 SwFltStackEntry& rEntry) override;
493 SwWW8FltRefStack(const SwWW8FltRefStack&) = delete;
494 SwWW8FltRefStack& operator=(const SwWW8FltRefStack&) = delete;
497 template< typename Type >
498 inline bool get_flag( Type nBitField, Type nMask )
499 { return (nBitField & nMask) != 0; }
501 template< typename ReturnType, typename Type >
502 inline ReturnType ulimit_cast( Type nValue, ReturnType nMax )
503 { return static_cast< ReturnType >( std::min< Type >( nValue, nMax ) ); }
505 template< typename ReturnType, typename Type >
506 inline ReturnType ulimit_cast( Type nValue )
507 { return ulimit_cast( nValue, std::numeric_limits< ReturnType >::max() ); }
509 class SwMacroInfo : public SdrObjUserData
511 public:
512 SwMacroInfo();
513 virtual ~SwMacroInfo() override;
515 SwMacroInfo(SwMacroInfo const &) = default;
516 SwMacroInfo(SwMacroInfo &&) = default;
517 SwMacroInfo & operator =(SwMacroInfo const &) = delete; // due to SdrObjUserData
518 SwMacroInfo & operator =(SwMacroInfo &&) = delete; // due to SdrObjUserData
520 virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* pObj ) const override;
522 void SetHlink( const OUString& rHlink ) { maHlink = rHlink; }
523 const OUString& GetHlink() const { return maHlink; }
524 void SetTarFrame( const OUString& rTarFrame ) { maTarFrame = rTarFrame; }
525 const OUString& GetTarFrame() const { return maTarFrame; }
526 void SetShapeId( sal_Int32 rShapeId ) { mnShapeId = rShapeId; }
527 const sal_Int32& GetShapeId() const { return mnShapeId; }
528 void SetName( const OUString& rName ) { maNameStr = rName; }
529 const OUString& GetName() const { return maNameStr; }
531 private:
532 sal_Int32 mnShapeId;
533 OUString maHlink;
534 OUString maNameStr;
535 OUString maTarFrame;
538 struct HyperLinksTable
540 OUString hLinkAddr;
541 OUString tarFrame;
544 namespace sw
546 namespace hack
548 class Position
550 private:
551 SwNodeIndex maPtNode;
552 sal_Int32 mnPtContent;
553 public:
554 explicit Position(const SwPosition &rPos);
555 operator SwPosition() const;
556 const SwNodeIndex& GetPtNode() const { return maPtNode; };
557 sal_Int32 GetPtContent() const { return mnPtContent; };
561 auto FilterControlChars(OUString const& rString) -> OUString;
564 class WW8FieldEntry
566 private:
567 OUString msBookmarkName;
568 OUString msMarkType;
569 OUString msMarkCode;
570 ::sw::mark::IFieldmark::parameter_map_t maParams;
572 public:
573 sw::hack::Position maStartPos;
574 sal_uInt16 mnFieldId;
575 sal_uLong mnObjLocFc;
576 WW8FieldEntry(SwPosition const &rPos, sal_uInt16 nFieldId) throw();
577 WW8FieldEntry(const WW8FieldEntry &rOther) throw();
578 WW8FieldEntry &operator=(const WW8FieldEntry &rOther) throw();
579 void Swap(WW8FieldEntry &rOther) throw();
581 SwNodeIndex GetPtNode() const { return maStartPos.GetPtNode(); };
582 sal_Int32 GetPtContent() const { return maStartPos.GetPtContent(); };
584 const OUString& GetBookmarkName() const { return msBookmarkName;}
585 const OUString& GetBookmarkCode() const { return msMarkCode;}
586 void SetBookmarkName(const OUString& bookmarkName);
587 void SetBookmarkType(const OUString& bookmarkType);
588 void SetBookmarkCode(const OUString& bookmarkCode);
589 ::sw::mark::IFieldmark::parameter_map_t& getParameters() { return maParams;}
592 // mini marker for some flags
594 class WW8ReaderSave
596 private:
597 WW8PLCFxSaveAll maPLCFxSave;
598 SwPosition maTmpPos;
599 std::deque<bool> maOldApos;
600 std::deque<WW8FieldEntry> maOldFieldStack;
601 std::unique_ptr<SwWW8FltControlStack> mxOldStck;
602 std::unique_ptr<SwWW8FltAnchorStack> mxOldAnchorStck;
603 std::unique_ptr<sw::util::RedlineStack> mxOldRedlines;
604 std::shared_ptr<WW8PLCFMan> mxOldPlcxMan;
605 std::unique_ptr<WW8FlyPara> mpWFlyPara;
606 std::unique_ptr<WW8SwFlyPara> mpSFlyPara;
607 SwPaM* mpPreviousNumPaM;
608 const SwNumRule* mpPrevNumRule;
609 std::unique_ptr<WW8TabDesc> mxTableDesc;
610 int mnInTable;
611 sal_uInt16 mnCurrentColl;
612 sal_Unicode mcSymbol;
613 bool mbIgnoreText;
614 bool mbSymbol;
615 bool mbHdFtFootnoteEdn;
616 bool mbTxbxFlySection;
617 bool mbAnl;
618 bool mbInHyperlink;
619 bool mbPgSecBreak;
620 bool mbWasParaEnd;
621 bool mbHasBorder;
622 bool mbFirstPara;
623 public:
624 WW8ReaderSave(SwWW8ImplReader* pRdr, WW8_CP nStart=-1);
625 void Restore(SwWW8ImplReader* pRdr);
626 const SwPosition &GetStartPos() const { return maTmpPos; }
629 enum class eF_ResT { OK, TEXT, TAGIGN, READ_FSPA };
631 class SwWW8Shade
633 public:
634 Color aColor;
635 SwWW8Shade(bool bVer67, const WW8_SHD& rSHD);
636 SwWW8Shade(Color nFore, Color nBack, sal_uInt16 nIndex)
638 SetShade(nFore, nBack, nIndex);
640 private:
641 void SetShade(Color nFore, Color nBack, sal_uInt16 nIndex);
644 // Formulas
646 enum SwWw8ControlType
648 WW8_CT_EDIT,
649 WW8_CT_CHECKBOX,
650 WW8_CT_DROPDOWN
653 class WW8FormulaControl
655 protected:
656 SwWW8ImplReader &mrRdr;
658 WW8FormulaControl(WW8FormulaControl const&) = delete;
659 WW8FormulaControl& operator=(WW8FormulaControl const&) = delete;
661 public:
662 WW8FormulaControl(const OUString& rN, SwWW8ImplReader &rRdr)
663 : mrRdr(rRdr), mfUnknown(0), mfDropdownIndex(0),
664 mfToolTip(0), mfNoMark(0), mfType(0),
665 mfUnused(0), mhpsCheckBox(20), mnChecked(0), mnMaxLen(0),
666 mbHelp(false), msName( rN )
669 sal_uInt8 mfUnknown:2;
670 sal_uInt8 mfDropdownIndex:6;
671 sal_uInt8 mfToolTip:1;
672 sal_uInt8 mfNoMark:1;
673 sal_uInt8 mfType:3;
674 sal_uInt8 mfUnused:3;
676 sal_uInt16 mhpsCheckBox;
677 sal_uInt16 mnChecked;
679 /// FFData.cch in the spec: maximum length, in characters, of the value of the textbox.
680 sal_uInt16 mnMaxLen;
681 OUString msTitle;
682 OUString msDefault;
683 OUString msFormatting;
684 bool mbHelp;
685 OUString msHelp;
686 OUString msToolTip;
687 OUString msEntryMcr;
688 OUString msExitMcr;
689 std::vector<OUString> maListEntries;
690 virtual ~WW8FormulaControl() {}
691 void FormulaRead(SwWw8ControlType nWhich,SvStream *pD);
692 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
693 css::uno::Reference< css::form::XFormComponent> &rFComp,
694 css::awt::Size &rSz) = 0;
695 OUString msName;
698 class WW8FormulaCheckBox : public WW8FormulaControl
700 private:
701 WW8FormulaCheckBox(const WW8FormulaCheckBox&) = delete;
702 WW8FormulaCheckBox& operator=(const WW8FormulaCheckBox&) = delete;
704 public:
705 explicit WW8FormulaCheckBox(SwWW8ImplReader &rR);
707 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
708 css::uno::Reference< css::form::XFormComponent> &rFComp,
709 css::awt::Size &rSz) override;
712 class WW8FormulaListBox : public WW8FormulaControl
714 private:
715 WW8FormulaListBox(const WW8FormulaListBox&) = delete;
716 WW8FormulaListBox& operator=(const WW8FormulaListBox&) = delete;
718 public:
719 explicit WW8FormulaListBox(SwWW8ImplReader &rR);
721 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> &rServiceFactory,
722 css::uno::Reference< css::form::XFormComponent> &rFComp,
723 css::awt::Size &rSz) override;
726 class WW8FormulaEditBox : public WW8FormulaControl
728 private:
729 WW8FormulaEditBox(const WW8FormulaEditBox&) = delete;
730 WW8FormulaEditBox& operator=(const WW8FormulaEditBox&) = delete;
731 public:
732 explicit WW8FormulaEditBox(SwWW8ImplReader &rR);
733 //no real implementation, return false
734 virtual bool Import(const css::uno::Reference< css::lang::XMultiServiceFactory> & /* rServiceFactory */,
735 css::uno::Reference< css::form::XFormComponent> & /* rFComp */,
736 css::awt::Size & /* rSz */) override { return false; }
739 class SwMSConvertControls: public oox::ole::MSConvertOCXControls
741 public:
742 SwMSConvertControls( SfxObjectShell const *pDSh, SwPaM *pP );
743 void InsertFormula( WW8FormulaControl &rFormula);
744 virtual bool InsertControl(const css::uno::Reference< css::form::XFormComponent >& rFComp,
745 const css::awt::Size& rSize,
746 css::uno::Reference< css::drawing::XShape > *pShape, bool bFloatingCtrl) override;
747 void ExportControl(WW8Export &rWrt, const SdrUnoObj& rFormObj);
748 bool ReadOCXStream( tools::SvRef<SotStorage> const & rSrc1,
749 css::uno::Reference< css::drawing::XShape > *pShapeRef,
750 bool bFloatingCtrl=false );
751 private:
752 SwPaM *pPaM;
753 sal_uInt32 mnObjectId;
756 class SwMSDffManager : public SvxMSDffManager
758 private:
759 SwWW8ImplReader& rReader;
760 SvStream *pFallbackStream;
761 std::unordered_map<sal_uInt32, Graphic> aOldEscherBlipCache;
763 virtual bool GetOLEStorageName( sal_uInt32 nOLEId, OUString& rStorageName,
764 tools::SvRef<SotStorage>& rSrcStorage, css::uno::Reference < css::embed::XStorage >& rDestStorage ) const override;
765 virtual bool ShapeHasText( sal_uLong nShapeId, sal_uLong nFilePos ) const override;
766 // #i32596# - new parameter <_nCalledByGroup>, which
767 // indicates, if the OLE object is imported inside a group object
768 virtual SdrObject* ImportOLE( sal_uInt32 nOLEId,
769 const Graphic& rGrf,
770 const tools::Rectangle& rBoundRect,
771 const tools::Rectangle& rVisArea,
772 const int _nCalledByGroup ) const override;
774 SwMSDffManager(const SwMSDffManager&) = delete;
775 SwMSDffManager& operator=(const SwMSDffManager&) = delete;
776 public:
777 static sal_uInt32 GetFilterFlags();
778 static sal_Int32 GetEscherLineMatch(MSO_LineStyle eStyle, MSO_SPT eShapeType,
779 sal_Int32 &rThick);
780 SwMSDffManager( SwWW8ImplReader& rRdr, bool bSkipImages );
781 void DisableFallbackStream();
782 void EnableFallbackStream();
783 protected:
784 virtual SdrObject* ProcessObj( SvStream& rSt, DffObjData& rObjData, SvxMSDffClientData& rData, tools::Rectangle& rTextRect, SdrObject* pObj ) override;
787 class wwSection
789 public:
790 explicit wwSection(const SwPosition &rPos);
791 SEPr maSep;
792 WW8_BRCVer9 brc[4];
793 SwNodeIndex maStart;
794 SwSection *mpSection;
795 SwPageDesc *mpPage;
796 SvxFrameDirection meDir;
798 sal_uInt32 nPgWidth;
799 sal_uInt32 nPgLeft;
800 sal_uInt32 nPgRight;
802 css::drawing::TextVerticalAdjust mnVerticalAdjustment;
803 sal_uInt8 mnBorders;
804 bool mbHasFootnote;
805 void SetDirection();
806 bool IsContinuous() const { return maSep.bkc == 0; }
807 bool IsNotProtected() const { return maSep.fUnlocked != 0; }
808 bool IsVertical() const;
809 sal_Int16 NoCols() const { return maSep.ccolM1 + 1; }
810 sal_Int32 StandardColSeparation() const { return maSep.dxaColumns; }
811 bool HasTitlePage() const { return maSep.fTitlePage != 0; }
812 sal_uInt16 PageStartAt() const { return maSep.pgnStart; }
813 bool PageRestartNo() const { return maSep.fPgnRestart != 0; }
814 bool IsBiDi() const { return maSep.fBiDi != 0; }
815 sal_uInt32 GetPageWidth() const { return nPgWidth; }
816 sal_uInt32 GetTextAreaWidth() const
817 { return GetPageWidth() - GetPageLeft() - GetPageRight(); }
818 sal_uInt32 GetPageHeight() const { return maSep.yaPage; }
819 sal_uInt32 GetPageLeft() const { return nPgLeft; }
820 sal_uInt32 GetPageRight() const { return nPgRight; }
821 bool IsLandScape() const { return maSep.dmOrientPage != 0; }
822 bool IsFixedHeightHeader() const { return maSep.dyaTop < 0; }
823 bool IsFixedHeightFooter() const { return maSep.dyaBottom < 0; }
826 class wwSectionManager
828 private:
830 A queue of the ms sections in the document
832 SwWW8ImplReader& mrReader;
833 std::deque<wwSection> maSegments;
834 typedef std::deque<wwSection>::iterator mySegIter;
836 //Num of page desc's entered into the document
837 sal_uInt16 mnDesc;
839 struct wwULSpaceData
841 bool bHasHeader, bHasFooter;
842 sal_uInt32 nSwHLo, nSwFUp, nSwUp, nSwLo;
843 wwULSpaceData()
844 : bHasHeader(false)
845 , bHasFooter(false)
846 , nSwHLo(0)
847 , nSwFUp(0)
848 , nSwUp(0)
849 , nSwLo(0)
853 void SetSegmentToPageDesc(const wwSection &rSection, bool bIgnoreCols);
855 void GetPageULData(const wwSection &rNewSection,
856 wwULSpaceData& rData) const;
857 static void SetPageULSpaceItems(SwFrameFormat &rFormat, wwULSpaceData const & rData,
858 const wwSection &rSection);
860 static void SetPage(SwPageDesc &rPageDesc, SwFrameFormat &rFormat,
861 const wwSection &rSection, bool bIgnoreCols);
863 static void SetNumberingType(const wwSection &rNewSection, SwPageDesc &rPageDesc);
865 void SetUseOn(wwSection &rSection);
866 void SetHdFt(wwSection const &rSection, int nSect, const wwSection *pPrevious);
868 SwSectionFormat *InsertSection(SwPaM const & rMyPaM, wwSection &rSection);
869 static bool SetCols(SwFrameFormat &rFormat, const wwSection &rSection,
870 sal_uInt32 nNetWidth);
871 bool SectionIsProtected(const wwSection &rSection) const;
872 void SetLeftRight(wwSection &rSection);
874 The segment we're inserting, the start of the segments container, and the
875 nodeindex of where we want the page break to (normally the segments start
876 position
878 SwFormatPageDesc SetSwFormatPageDesc(mySegIter const &rIter, mySegIter const &rStart,
879 bool bIgnoreCols);
881 wwSectionManager(const wwSectionManager&) = delete;
882 wwSectionManager& operator=(const wwSectionManager&) = delete;
883 public:
884 explicit wwSectionManager(SwWW8ImplReader &rReader) : mrReader(rReader), mnDesc(0)
886 void SetCurrentSectionHasFootnote();
887 void SetCurrentSectionVerticalAdjustment(const css::drawing::TextVerticalAdjust nVA);
888 bool CurrentSectionIsVertical() const;
889 bool CurrentSectionIsProtected() const;
890 void PrependedInlineNode(const SwPosition &rPos, const SwNode &rNode);
891 sal_uInt16 CurrentSectionColCount() const;
892 bool WillHavePageDescHere(const SwNodeIndex& rIdx) const;
893 void CreateSep(const tools::Long nTextPos);
894 void InsertSegments();
895 void JoinNode(const SwPosition &rPos, const SwNode &rNode);
896 sal_uInt32 GetPageLeft() const;
897 sal_uInt32 GetPageRight() const;
898 sal_uInt32 GetPageWidth() const;
899 sal_uInt32 GetWWPageTopMargin() const;
900 sal_uInt32 GetTextAreaWidth() const;
903 //Various writer elements like frames start off containing a blank paragraph,
904 //sometimes this paragraph turns out to be extraneous, e.g. the frame should
905 //only contain a table with no trailing paragraph.
907 //We want to remove these extra paragraphs, but removing them during the parse
908 //is problematic, because we don't want to remove any paragraphs that are still
909 //addressed by property entries in a SwFltControlStack which have not yet been
910 //committed to the document.
912 //Safest thing is to not delete SwTextNodes from a document during import, and
913 //remove these extraneous paragraphs at the end after all SwFltControlStack are
914 //destroyed.
915 class wwExtraneousParas
917 private:
919 A vector of SwTextNodes to erase from a document after import is complete
921 std::set<SwTextNode*, SwWW8::ltnode> m_aTextNodes;
922 SwDoc& m_rDoc;
924 wwExtraneousParas(wwExtraneousParas const&) = delete;
925 wwExtraneousParas& operator=(wwExtraneousParas const&) = delete;
927 public:
928 explicit wwExtraneousParas(SwDoc &rDoc) : m_rDoc(rDoc) {}
929 ~wwExtraneousParas() { delete_all_from_doc(); }
930 void insert(SwTextNode *pTextNode) { m_aTextNodes.insert(pTextNode); }
931 void delete_all_from_doc();
934 class wwFrameNamer
936 private:
937 OUString msSeed;
938 sal_Int32 mnImportedGraphicsCount;
939 bool mbIsDisabled;
941 wwFrameNamer(wwFrameNamer const&) = delete;
942 wwFrameNamer& operator=(wwFrameNamer const&) = delete;
944 public:
945 void SetUniqueGraphName(SwFrameFormat *pFrameFormat, const OUString &rFixedPart);
946 wwFrameNamer(bool bIsDisabled, const OUString &rSeed)
947 : msSeed(rSeed), mnImportedGraphicsCount(0), mbIsDisabled(bIsDisabled)
952 class wwSectionNamer
954 private:
955 const SwDoc &mrDoc;
956 OUString msFileLinkSeed;
957 int mnFileSectionNo;
958 wwSectionNamer(const wwSectionNamer&) = delete;
959 wwSectionNamer& operator=(const wwSectionNamer&) = delete;
960 public:
961 OUString UniqueName();
962 wwSectionNamer(const SwDoc &rDoc, const OUString &rSeed)
963 : mrDoc(rDoc), msFileLinkSeed(rSeed), mnFileSectionNo(0)
967 class FootnoteDescriptor
969 public:
970 ManTypes meType;
971 bool mbAutoNum;
972 WW8_CP mnStartCp;
973 WW8_CP mnLen;
976 struct ApoTestResults
978 bool mbStartApo;
979 bool mbStopApo;
980 bool m_bHasSprm37;
981 bool m_bHasSprm29;
982 sal_uInt8 m_nSprm29;
983 WW8FlyPara* mpStyleApo;
984 ApoTestResults()
985 : mbStartApo(false), mbStopApo(false), m_bHasSprm37(false)
986 , m_bHasSprm29(false), m_nSprm29(0), mpStyleApo(nullptr) {}
987 bool HasStartStop() const { return (mbStartApo || mbStopApo); }
988 bool HasFrame() const { return (m_bHasSprm29 || m_bHasSprm37 || mpStyleApo); }
991 struct ANLDRuleMap
993 OUString msOutlineNumRule; // WinWord 6 numbering, variant 1
994 OUString msNumberingNumRule; // WinWord 6 numbering, variant 2
995 SwNumRule* GetNumRule(const SwDoc& rDoc, sal_uInt8 nNumType);
996 void SetNumRule(const OUString& rNumRule, sal_uInt8 nNumType);
999 struct SprmReadInfo;
1000 class SwDocShell;
1001 struct WW8PostProcessAttrsInfo
1003 bool mbCopy;
1004 WW8_CP mnCpStart;
1005 WW8_CP mnCpEnd;
1006 SwPaM mPaM;
1007 SfxItemSet mItemSet;
1009 WW8PostProcessAttrsInfo(WW8_CP nCpStart, WW8_CP nCpEnd, SwPaM & rPaM);
1012 #define MAX_COL 64 // WW6-description: 32, WW6-UI: 31 & WW8-UI: 63!
1014 struct WW8TabBandDesc
1016 WW8TabBandDesc* pNextBand;
1017 short nGapHalf;
1018 short mnDefaultLeft;
1019 short mnDefaultTop;
1020 short mnDefaultRight;
1021 short mnDefaultBottom;
1022 bool mbHasSpacing;
1023 short nLineHeight;
1024 short nRows;
1025 sal_uInt16 maDirections[MAX_COL + 1];
1026 short nCenter[MAX_COL + 1]; // X-edge of all cells of this band
1027 short nWidth[MAX_COL + 1]; // length of all cells of this band
1028 short nWwCols; // sal_uInt8 would be sufficient, alignment -> short
1029 short nSwCols; // SW: number of columns for the writer
1030 bool bLEmptyCol; // SW: an additional empty column at the left
1031 bool bREmptyCol; // SW: same at the right
1032 bool bCantSplit;
1033 bool bCantSplit90;
1034 WW8_TCell* pTCs;
1035 sal_uInt8 nOverrideSpacing[MAX_COL + 1];
1036 short nOverrideValues[MAX_COL + 1][4];
1037 WW8_SHD* pSHDs;
1038 Color* pNewSHDs;
1039 WW8_BRCVer9 aDefBrcs[6];
1041 bool bExist[MAX_COL]; // does this cell exist ?
1042 sal_uInt8 nTransCell[MAX_COL + 2]; // translation WW-Index -> SW-Index
1044 sal_uInt8 transCell(sal_uInt8 nWwCol) const
1046 return nWwCol < SAL_N_ELEMENTS(nTransCell) ? nTransCell[nWwCol] : 0xFF;
1049 WW8TabBandDesc();
1050 WW8TabBandDesc(WW8TabBandDesc const & rBand); // deep copy
1051 ~WW8TabBandDesc();
1052 void ReadDef(bool bVer67, const sal_uInt8* pS, short nLen);
1053 void ProcessDirection(const sal_uInt8* pParams);
1054 void ProcessSprmTSetBRC(int nBrcVer, const sal_uInt8* pParamsTSetBRC, sal_uInt16 nParamsLen);
1055 void ProcessSprmTTableBorders(int nBrcVer, const sal_uInt8* pParams, sal_uInt16 nParamsLen);
1056 void ProcessSprmTDxaCol(const sal_uInt8* pParamsTDxaCol);
1057 void ProcessSprmTDelete(const sal_uInt8* pParamsTDelete);
1058 void ProcessSprmTInsert(const sal_uInt8* pParamsTInsert);
1059 void ProcessSpacing(const sal_uInt8* pParamsTInsert);
1060 void ProcessSpecificSpacing(const sal_uInt8* pParamsTInsert);
1061 void ReadShd(const sal_uInt8* pS );
1062 void ReadNewShd(const sal_uInt8* pS, bool bVer67, sal_uInt8 nStart);
1064 enum wwDIR {wwTOP = 0, wwLEFT = 1, wwBOTTOM = 2, wwRIGHT = 3};
1066 private:
1067 WW8TabBandDesc & operator =(WW8TabBandDesc const &) = default; // only for use in copy ctor
1070 // Storage-Reader
1072 typedef std::set<WW8_CP> cp_set;
1074 class SwWW8ImplReader
1076 private:
1077 SwDocShell *m_pDocShell; // The Real DocShell
1079 friend class WW8RStyle;
1080 friend class WW8TabDesc;
1081 friend class WW8ReaderSave;
1082 friend struct WW8FlyPara;
1083 friend struct WW8SwFlyPara;
1084 friend class WW8FlySet;
1085 friend class SwMSDffManager;
1086 friend class SwWW8FltControlStack;
1087 friend class WW8FormulaControl;
1088 friend class wwSectionManager;
1090 private:
1092 SotStorage* m_pStg; // Input-Storage
1093 SvStream* m_pStrm; // Input-(Storage)Stream
1094 SvStream* m_pTableStream; // Input-(Storage)Stream
1095 SvStream* m_pDataStream; // Input-(Storage)Stream
1097 // general stuff
1098 SwDoc& m_rDoc;
1099 std::shared_ptr<SwUnoCursor> mpCursor;
1100 SwPaM* m_pPaM;
1102 std::unique_ptr<SwWW8FltControlStack> m_xCtrlStck; // stack for the attributes
1105 This stack is for redlines, because their sequence of discovery can
1106 be out of order of their order of insertion into the document.
1108 std::unique_ptr<sw::util::RedlineStack> m_xRedlineStack;
1111 This stack is for fields that get referenced later, e.g. BookMarks and TOX.
1112 They get inserted at the end of the document, it is the same stack for
1113 headers/footers/main text/textboxes/tables etc...
1115 std::unique_ptr<SwWW8ReferencedFltEndStack> m_xReffedStck;
1118 This stack is for fields whose true conversion cannot be determined until
1119 the end of the document, it is the same stack for headers/footers/main
1120 text/textboxes/tables etc... They are things that reference other things
1121 e.g. NoteRef and Ref, they are processed after m_xReffedStck
1123 std::unique_ptr<SwWW8FltRefStack> m_xReffingStck;
1126 For graphics anchors. Determines the graphics whose anchors are in the
1127 current paragraph, and works around the difficulty in inserting a graphic
1128 anchored to character before a character to be anchored to has been
1129 inserted. Is emptied at the end of each paragraph.
1131 std::unique_ptr<SwWW8FltAnchorStack> m_xAnchorStck;
1134 A stack of fields identifiers to keep track of any open fields that need
1135 to be closed. Generally word fields are inserted as writer fields as soon
1136 as they are encountered, and so their end point is normally unimportant.
1137 But hyperlink fields need to be applied as attributes to text and it is
1138 far easier and safer to set the end point of an attribute when we
1139 encounter the end marker of the field instead of calculating in advance
1140 where the end point will fall, to do so fully correctly duplicates the
1141 main logic of the filter itself.
1143 std::deque<WW8FieldEntry> m_aFieldStack;
1146 A stack of open footnotes. Should only be one in it at any time.
1148 std::deque<FootnoteDescriptor> m_aFootnoteStack;
1151 A queue of the ms sections in the document
1153 wwSectionManager m_aSectionManager;
1156 A vector of surplus-to-requirements paragraph in the final document,
1157 that exist because of quirks of the SwDoc document model and/or API,
1158 which need to be removed.
1160 wwExtraneousParas m_aExtraneousParas;
1163 A map of tables to their follow nodes for use in inserting tables into
1164 already existing document, i.e. insert file
1166 sw::util::InsertedTablesManager m_aInsertedTables;
1169 Creates unique names to give to (file link) sections (WW1/WW2/...)
1171 wwSectionNamer m_aSectionNameGenerator;
1174 Knows how to split a series of bytes into sprms and their arguments
1176 std::unique_ptr<wwSprmParser> m_xSprmParser;
1179 Creates unique names to give to graphics
1181 wwFrameNamer m_aGrfNameGenerator;
1184 Knows which writer style a given word style should be imported as.
1186 sw::util::ParaStyleMapper m_aParaStyleMapper;
1187 sw::util::CharStyleMapper m_aCharStyleMapper;
1190 Stack of textencoding being used as we progress through the document text
1192 std::stack<rtl_TextEncoding> m_aFontSrcCharSets;
1193 std::stack<rtl_TextEncoding> m_aFontSrcCJKCharSets;
1196 Progress bar
1198 std::unique_ptr<ImportProgress> m_xProgress;
1200 std::unique_ptr<SwMSConvertControls> m_xFormImpl; // implementation of control
1202 SwFlyFrameFormat* m_pFlyFormatOfJustInsertedGraphic;
1203 std::unique_ptr<FrameDeleteWatch> m_xFormatOfJustInsertedApo;
1204 SwPaM* m_pPreviousNumPaM;
1205 const SwNumRule* m_pPrevNumRule;
1207 //Keep track of APO environments
1208 std::deque<bool> m_aApos;
1210 Keep track of generated Ruby character formats we can minimize the
1211 number of character formats created
1213 std::vector<const SwCharFormat*> m_aRubyCharFormats;
1216 For fuzzing keep track of source offset of inserted graphics
1218 std::set<sal_uLong> m_aGrafPosSet;
1220 std::unique_ptr<WW8PostProcessAttrsInfo> m_pPostProcessAttrsInfo;
1222 std::shared_ptr<WW8Fib> m_xWwFib;
1223 std::unique_ptr<WW8Fonts> m_xFonts;
1224 std::unique_ptr<WW8Dop> m_xWDop;
1225 std::unique_ptr<WW8ListManager, o3tl::default_delete<WW8ListManager>> m_xLstManager;
1226 std::unique_ptr<WW8ScannerBase> m_xSBase;
1227 std::shared_ptr<WW8PLCFMan> m_xPlcxMan;
1228 std::map<short, OUString> m_aLinkStringMap;
1230 o3tl::sorted_vector<const SwNode*> m_aTextNodesHavingFirstLineOfstSet; // #i103711#
1231 o3tl::sorted_vector<const SwNode*> m_aTextNodesHavingLeftIndentSet; // #i105414#
1233 std::unique_ptr<WW8RStyle> m_xStyles; // pointer to the style reading class
1234 SwFormat* m_pCurrentColl; // collection to be created now
1235 // ( always 0 outside of a Style-Def )
1236 std::unique_ptr<SfxItemSet> m_xCurrentItemSet;// character attributes to be read in now
1237 // (always 0 outside of the WW8ListManager Ctor)
1238 std::vector<SwWW8StyInf> m_vColl;
1239 const SwTextFormatColl* m_pDfltTextFormatColl; // Default
1240 SwFormat* m_pStandardFormatColl;// "Standard"
1242 std::unique_ptr<WW8PLCF_HdFt> m_xHdFt; // pointer to Header / Footer - scanner class
1244 std::unique_ptr<WW8FlyPara> m_xWFlyPara; // WW-parameter
1245 std::unique_ptr<WW8SwFlyPara> m_xSFlyPara; // Sw parameters created from previous
1247 std::unique_ptr<WW8TabDesc> m_xTableDesc; // description of table properties
1248 //Keep track of tables within tables
1249 std::stack<std::unique_ptr<WW8TabDesc>> m_aTableStack;
1251 ANLDRuleMap m_aANLDRules;
1252 std::unique_ptr<WW8_OLST> m_xNumOlst; // position in text
1254 SdrModel* m_pDrawModel;
1255 SdrPage* m_pDrawPg;
1256 std::unique_ptr<EditEngine> m_pDrawEditEngine;
1257 std::unique_ptr<wwZOrderer> m_xWWZOrder;
1259 SwFieldType* m_pNumFieldType; // for number circle
1261 std::unique_ptr<SwMSDffManager> m_xMSDffManager;
1263 std::unique_ptr<std::vector<OUString>> m_pAtnNames;
1265 std::unique_ptr<WW8SmartTagData> m_pSmartTagData;
1267 sw::util::AuthorInfos m_aAuthorInfos;
1268 OUString m_sBaseURL;
1270 // Ini-Flags:
1271 sal_uInt32 m_nIniFlags; // flags from writer.ini
1272 sal_uInt32 m_nIniFlags1; // ditto ( additional flags )
1273 sal_uInt32 m_nFieldFlags; // ditto for fields
1274 sal_uInt32 m_nFieldTagAlways[3]; // ditto for tagging of fields
1275 sal_uInt32 m_nFieldTagBad[3]; // ditto for tagging of fields that can't be imported
1276 bool m_bRegardHindiDigits; // import digits in CTL scripts as Hindi numbers
1278 bool m_bDrawCpOValid;
1279 WW8_CP m_nDrawCpO; // start of Txbx-SubDocs
1281 sal_uLong m_nPicLocFc; // Picture Location in File (FC)
1282 sal_uLong m_nObjLocFc; // Object Location in File (FC)
1284 sal_Int32 m_nIniFlyDx; // X-offset of Flys
1285 sal_Int32 m_nIniFlyDy; // Y-offset of Flys
1287 rtl_TextEncoding m_eTextCharSet; // Default charset for Text
1288 rtl_TextEncoding m_eStructCharSet; // rtl_TextEncoding for structures
1289 rtl_TextEncoding m_eHardCharSet; // Hard rtl_TextEncoding-Attribute
1290 sal_uInt16 m_nProgress; // percentage for Progressbar
1291 sal_uInt16 m_nCurrentColl; // per WW-count
1292 sal_uInt16 m_nFieldNum; // serial number for that
1293 sal_uInt16 m_nLFOPosition;
1295 short m_nCharFormat; // per WW-count, <0 for none
1297 short m_nDrawXOfs, m_nDrawYOfs;
1298 short m_nDrawXOfs2, m_nDrawYOfs2;
1300 sal_Unicode m_cSymbol; // symbol to be read now
1302 sal_uInt8 m_nWantedVersion; // originally requested WW-Doc version by Writer
1304 sal_uInt8 m_nSwNumLevel; // level number for outline / enumeration
1305 sal_uInt8 m_nWwNumType; // outline / number / enumeration
1306 sal_uInt8 m_nListLevel;
1308 bool m_bNewDoc; // new document?
1309 bool m_bSkipImages; // skip images for text extraction/indexing
1310 bool m_bReadNoTable; // no tables
1311 bool m_bPgSecBreak; // Page- or Sectionbreak is still to be added
1312 bool m_bSpec; // special char follows in text
1313 bool m_bObj; // Obj in Text
1314 bool m_bTxbxFlySection; // FlyFrame that was inserted as replacement for Winword Textbox
1315 bool m_bHasBorder; // for bundling of the borders
1316 bool m_bSymbol; // e.g. Symbol instead of Times
1317 bool m_bIgnoreText; // e.g. for FieldVanish
1318 int m_nInTable; // are we currently reading a table?
1319 bool m_bWasTabRowEnd; // table : Row End Mark
1320 bool m_bWasTabCellEnd; // table: Cell End Mark
1322 bool m_bAnl; // enumeration in work
1323 // Anl stands for "Autonumber level"
1325 bool m_bHdFtFootnoteEdn; // special text: header/footer/and so on
1326 bool m_bFootnoteEdn; // footnote or endnote
1327 bool m_bIsHeader; // text is read from header ( line height )
1328 bool m_bIsFooter; // text is read from footer ( line height )
1330 bool m_bIsUnicode; // current piece of text is encoded as 2-byte Unicode
1331 // please do NOT handle this as bit field!
1333 bool m_bCpxStyle; // style in the complex part
1334 bool m_bStyNormal; // style with Id 0 is currently read
1335 bool m_bWWBugNormal; // WW-Version with Bug Dya in Style Normal
1336 bool m_bNoAttrImport; // ignore attributes for ignoring styles
1337 bool m_bInHyperlink; // special case for reading 0x01
1338 // see also: SwWW8ImplReader::Read_F_Hyperlink()
1339 bool m_bWasParaEnd;
1341 // useful helper variables
1342 bool m_bVer67; // ( (6 == nVersion) || (7 == nVersion) );
1343 bool m_bVer6; // (6 == nVersion);
1344 bool m_bVer7; // (7 == nVersion);
1345 bool m_bVer8; // (8 == nVersion);
1347 bool m_bEmbeddObj; // EmbeddField is being read
1349 bool m_bCurrentAND_fNumberAcross; // current active Annotated List Descriptor - ROW flag
1351 bool m_bNoLnNumYet; // no Line Numbering has been activated yet (we import
1352 // the very 1st Line Numbering and ignore the rest)
1354 bool m_bFirstPara; // first paragraph?
1355 bool m_bFirstParaOfPage;
1356 bool m_bParaAutoBefore;
1357 bool m_bParaAutoAfter;
1359 bool m_bDropCap;
1360 sal_Int32 m_nDropCap;
1362 bool m_bBidi;
1363 bool m_bReadTable;
1364 // Indicate that currently on loading a TOC, managed by Read_F_TOX() and End_Field()
1365 bool m_bLoadingTOXCache;
1366 int m_nEmbeddedTOXLevel;
1367 // Indicate that current on loading a hyperlink, which is inside a TOC; Managed by Read_F_Hyperlink() and End_Field()
1368 bool m_bLoadingTOXHyperlink;
1369 // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
1370 std::unique_ptr<SwPaM> m_pPosAfterTOC;
1371 // used for some dropcap tweaking
1372 SwTextNode* m_pPreviousNode;
1374 std::unique_ptr< SwPosition > m_pLastAnchorPos;
1376 bool m_bCareFirstParaEndInToc;
1377 bool m_bCareLastParaEndInToc;
1378 cp_set m_aTOXEndCps;
1380 std::vector<WW8_CP> m_aEndParaPos;
1381 WW8_CP m_aCurrAttrCP;
1382 bool m_bOnLoadingMain:1;
1383 bool m_bNotifyMacroEventRead:1;
1385 const SprmReadInfo& GetSprmReadInfo(sal_uInt16 nId) const;
1387 bool StyleExists(unsigned int nColl) const { return (nColl < m_vColl.size()); }
1388 SwWW8StyInf *GetStyle(sal_uInt16 nColl) const;
1389 void AppendTextNode(SwPosition& rPos);
1391 void Read_HdFt(int nSect, const SwPageDesc *pPrev,
1392 const wwSection &rSection);
1393 void Read_HdFtText(WW8_CP nStartCp, WW8_CP nLen, SwFrameFormat const * pHdFtFormat);
1394 void Read_HdFtTextAsHackedFrame(WW8_CP nStart, WW8_CP nLen,
1395 SwFrameFormat const &rHdFtFormat, sal_uInt16 nPageWidth);
1397 bool isValid_HdFt_CP(WW8_CP nHeaderCP) const;
1399 bool HasOwnHeaderFooter(sal_uInt8 nWhichItems, sal_uInt8 grpfIhdt, int nSect);
1401 void HandleLineNumbering(const wwSection &rSection);
1403 void CopyPageDescHdFt( const SwPageDesc* pOrgPageDesc,
1404 SwPageDesc* pNewPageDesc, sal_uInt8 nCode );
1406 void DeleteStack(std::unique_ptr<SwFltControlStack> prStck);
1407 void DeleteCtrlStack()
1409 DeleteStack(std::move(m_xCtrlStck));
1411 void DeleteRefStacks()
1413 DeleteStack(std::move(m_xReffedStck));
1414 DeleteStack(std::move(m_xReffingStck));
1416 void DeleteAnchorStack()
1418 DeleteStack(std::move(m_xAnchorStck));
1420 void emulateMSWordAddTextToParagraph(const OUString& rAddString);
1421 void simpleAddTextToParagraph(const OUString& rAddString);
1422 bool HandlePageBreakChar();
1423 bool ReadChar(tools::Long nPosCp, tools::Long nCpOfs);
1424 bool ReadPlainChars(WW8_CP& rPos, sal_Int32 nEnd, sal_Int32 nCpOfs);
1425 bool ReadChars(WW8_CP& rPos, WW8_CP nNextAttr, tools::Long nTextEnd, tools::Long nCpOfs);
1426 static bool LangUsesHindiNumbers(LanguageType nLang);
1427 static sal_Unicode TranslateToHindiNumbers(sal_Unicode);
1429 void SetDocumentGrid(SwFrameFormat &rFormat, const wwSection &rSection);
1431 void ProcessCurrentCollChange(WW8PLCFManResult& rRes, bool* pStartAttr,
1432 bool bCallProcessSpecial);
1433 tools::Long ReadTextAttr(WW8_CP& rTextPos, tools::Long nTextEnd, bool& rbStartLine, int nDepthGuard = 0);
1434 void ReadAttrs(WW8_CP& rTextPos, WW8_CP& rNext, tools::Long nTextEnd, bool& rbStartLine);
1435 void CloseAttrEnds();
1436 bool ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType);
1438 void ReadRevMarkAuthorStrTabl( SvStream& rStrm, sal_Int32 nTablePos,
1439 sal_Int32 nTableSiz, SwDoc& rDoc );
1441 void Read_HdFtFootnoteText(const SwNodeIndex* pSttIdx, WW8_CP nStartCp,
1442 WW8_CP nLen, ManTypes nType);
1444 void ImportTox( int nFieldId, const OUString& aStr );
1446 void EndSprm( sal_uInt16 nId );
1447 // #i103711#
1448 // #i105414#
1449 void NewAttr( const SfxPoolItem& rAttr,
1450 const bool bFirstLineOfStSet = false,
1451 const bool bLeftIndentSet = false );
1453 bool GetFontParams(sal_uInt16, FontFamily&, OUString&, FontPitch&,
1454 rtl_TextEncoding&);
1455 bool SetNewFontAttr(sal_uInt16 nFCode, bool bSetEnums, sal_uInt16 nWhich);
1456 void ResetCharSetVars();
1457 void ResetCJKCharSetVars();
1459 const SfxPoolItem* GetFormatAttr( sal_uInt16 nWhich );
1460 bool JoinNode(SwPaM &rPam, bool bStealAttr = false);
1462 static bool IsBorder(const WW8_BRCVer9* pbrc, bool bChkBtwn = false);
1464 //Set closest writer border equivalent into rBox from pbrc, optionally
1465 //recording true winword dimensions in pSizeArray. nSetBorders to mark a
1466 //border which has been previously set to a value and for which becoming
1467 //empty is valid. Set bCheBtwn to work with paragraphs that have a special
1468 //between paragraphs border
1470 // Note #i20672# we can't properly support between lines so best to ignore
1471 // them for now
1472 static bool SetBorder(SvxBoxItem& rBox, const WW8_BRCVer9* pbrc,
1473 short *pSizeArray=nullptr, sal_uInt8 nSetBorders=0xFF);
1474 static void GetBorderDistance(const WW8_BRCVer9* pbrc, tools::Rectangle& rInnerDist);
1475 static sal_uInt16 GetParagraphAutoSpace(bool fDontUseHTMLAutoSpacing);
1476 static bool SetShadow(SvxShadowItem& rShadow, const short *pSizeArray,
1477 const WW8_BRCVer9& aRightBrc);
1478 //returns true is a shadow was set
1479 static bool SetFlyBordersShadow(SfxItemSet& rFlySet, const WW8_BRCVer9 *pbrc,
1480 short *SizeArray);
1481 static void SetPageBorder(SwFrameFormat &rFormat, const wwSection &rSection);
1483 static sal_Int32 MatchSdrBoxIntoFlyBoxItem( const Color& rLineColor,
1484 MSO_LineStyle eLineStyle, MSO_LineDashing eDashing, MSO_SPT eShapeType, sal_Int32 &rLineWidth,
1485 SvxBoxItem& rBox );
1486 void MatchSdrItemsIntoFlySet( SdrObject const * pSdrObj, SfxItemSet &aFlySet,
1487 MSO_LineStyle eLineStyle, MSO_LineDashing eDashing, MSO_SPT eShapeType, tools::Rectangle &rInnerDist );
1488 static void AdjustLRWrapForWordMargins(const SvxMSDffImportRec &rRecord,
1489 SvxLRSpaceItem &rLR);
1490 static void AdjustULWrapForWordMargins(const SvxMSDffImportRec &rRecord,
1491 SvxULSpaceItem &rUL);
1492 static void MapWrapIntoFlyFormat(SvxMSDffImportRec const * pRecord, SwFrameFormat* pFlyFormat);
1494 void SetAttributesAtGrfNode(SvxMSDffImportRec const* pRecord,
1495 SwFrameFormat const *pFlyFormat, WW8_FSPA const *pF);
1497 bool IsDropCap() const;
1498 bool IsListOrDropcap() const { return (!m_xCurrentItemSet || m_bDropCap); };
1500 //Apo == Absolutely Positioned Object, MSWord's old-style frames
1501 std::unique_ptr<WW8FlyPara> ConstructApo(const ApoTestResults &rApo,
1502 const WW8_TablePos *pTabPos);
1503 bool StartApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
1504 void StopApo();
1505 bool TestSameApo(const ApoTestResults &rApo, const WW8_TablePos *pTabPos);
1506 ApoTestResults TestApo(int nCellLevel, bool bTableRowEnd,
1507 const WW8_TablePos *pTabPos);
1508 static void StripNegativeAfterIndent(SwFrameFormat const *pFlyFormat);
1510 void EndSpecial();
1511 bool ProcessSpecial(bool &rbReSync, WW8_CP nStartCp);
1512 sal_uInt16 TabRowSprm(int nLevel) const;
1514 bool ReadGrafFile(OUString& rFileName, std::unique_ptr<Graphic>& rpGraphic,
1515 const WW8_PIC& rPic, SvStream* pSt, sal_uLong nFilePos, bool* pDelIt);
1517 static void ReplaceObj(const SdrObject &rReplaceTextObj,
1518 SdrObject &rSubObj);
1520 SwFlyFrameFormat* MakeGrafNotInContent(const WW8PicDesc& rPD,
1521 const Graphic* pGraph, const OUString& rFileName,
1522 const SfxItemSet& rGrfSet);
1524 SwFrameFormat* MakeGrafInContent(const WW8_PIC& rPic, const WW8PicDesc& rPD,
1525 const Graphic* pGraph, const OUString& rFileName,
1526 const SfxItemSet& rGrfSet);
1528 SwFrameFormat *AddAutoAnchor(SwFrameFormat *pFormat);
1529 SwFrameFormat* ImportGraf1(WW8_PIC const & rPic, SvStream* pSt, sal_uLong nFilePos);
1530 SwFrameFormat* ImportGraf(SdrTextObj const * pTextObj = nullptr, SwFrameFormat const * pFlyFormat = nullptr);
1532 SdrObject* ImportOleBase( Graphic& rGraph, const Graphic* pGrf=nullptr,
1533 const SfxItemSet* pFlySet=nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
1535 SwFrameFormat* ImportOle( const Graphic* = nullptr, const SfxItemSet* pFlySet = nullptr,
1536 const SfxItemSet* pGrfSet = nullptr, const tools::Rectangle& aVisArea = tools::Rectangle() );
1537 SwFlyFrameFormat* InsertOle(SdrOle2Obj &rObject, const SfxItemSet &rFlySet,
1538 const SfxItemSet *rGrfSet);
1540 bool ImportFormulaControl(WW8FormulaControl &rBox,WW8_CP nStart,
1541 SwWw8ControlType nWhich);
1543 void ImportDop();
1545 //This converts MS Asian Typography information into OOo's
1546 void ImportDopTypography(const WW8DopTypography &rTypo);
1548 ErrCode LoadThroughDecryption(WW8Glossary *pGloss);
1549 ErrCode SetSubStreams(tools::SvRef<SotStorageStream> &rTableStream, tools::SvRef<SotStorageStream> &rDataStream);
1550 ErrCode CoreLoad(WW8Glossary const *pGloss);
1552 void ReadDocVars();
1554 bool StartTable(WW8_CP nStartCp);
1555 bool InEqualApo(int nLvl) const;
1556 bool InLocalApo() const { return InEqualApo(m_nInTable); }
1557 bool InEqualOrHigherApo(int nLvl) const;
1558 void TabCellEnd();
1559 void StopTable();
1560 bool IsInvalidOrToBeMergedTabCell() const;
1562 // Enumerations / lists ( Autonumbered List Data Descriptor )
1563 // list: ANLD ( Autonumbered List Data Descriptor )
1564 // one level: ANLV ( Autonumber Level Descriptor )
1566 // Chg7-8:
1567 // lists are separate structures in WW8 that are handled via the following three tables:
1568 // rglst, hpllfo and hsttbListNames
1569 // the corresponding structures are: LSTF, LVLF, LFO LFOLVL
1571 void SetAnlvStrings(SwNumFormat &rNum, WW8_ANLV const &rAV, const sal_uInt8* pText,
1572 size_t nStart, size_t nElements, bool bOutline);
1573 void SetAnld(SwNumRule* pNumR, WW8_ANLD const * pAD, sal_uInt8 nSwLevel, bool bOutLine);
1574 void SetNumOlst( SwNumRule* pNumR, WW8_OLST* pO, sal_uInt8 nSwLevel );
1575 SwNumRule* GetStyRule();
1577 void StartAnl(const sal_uInt8* pSprm13);
1578 void NextAnlLine(const sal_uInt8* pSprm13);
1579 void StopAllAnl(bool bGoBack = true);
1580 void StopAnlToRestart(sal_uInt8 nType, bool bGoBack = true);
1582 // graphics layer
1584 bool ReadGrafStart(void* pData, short nDataSiz, WW8_DPHEAD const * pHd,
1585 SfxAllItemSet &rSet);
1586 SdrObject *ReadLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1587 SdrObject *ReadRect(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1588 SdrObject *ReadEllipse(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1589 SdrObject *ReadArc(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1590 SdrObject *ReadPolyLine(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1591 void InsertTxbxStyAttrs( SfxItemSet& rS, sal_uInt16 nColl );
1592 void InsertAttrsAsDrawingAttrs(WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType, bool bONLYnPicLocFc=false);
1594 bool GetTxbxTextSttEndCp(WW8_CP& rStartCp, WW8_CP& rEndCp, sal_uInt16 nTxBxS,
1595 sal_uInt16 nSequence);
1596 sal_Int32 GetRangeAsDrawingString(OUString& rString, tools::Long StartCp, tools::Long nEndCp, ManTypes eType);
1597 std::unique_ptr<OutlinerParaObject> ImportAsOutliner(OUString &rString, WW8_CP nStartCp, WW8_CP nEndCp, ManTypes eType);
1598 void InsertTxbxText(SdrTextObj* pTextObj, Size const * pObjSiz,
1599 sal_uInt16 nTxBxS, sal_uInt16 nSequence, tools::Long nPosCp, SwFrameFormat const * pFlyFormat,
1600 bool bMakeSdrGrafObj, bool& rbEraseTextObj,
1601 bool* pbTestTxbxContainsText = nullptr, tools::Long* pnStartCp = nullptr,
1602 tools::Long* pnEndCp = nullptr, bool* pbContainsGraphics = nullptr,
1603 SvxMSDffImportRec const * pRecord = nullptr);
1604 bool TxbxChainContainsRealText( sal_uInt16 nTxBxS,
1605 tools::Long& rStartCp,
1606 tools::Long& rEndCp );
1607 SdrObject *ReadTextBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1608 SdrObject *ReadCaptionBox(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1609 SdrObject *ReadGroup(WW8_DPHEAD const * pHd, SfxAllItemSet &rSet);
1610 SdrObject *ReadGrafPrimitive(short& rLeft, SfxAllItemSet &rSet);
1611 void ReadGrafLayer1( WW8PLCFspecial* pPF, tools::Long nGrafAnchorCp );
1612 SdrObject* CreateContactObject(SwFrameFormat* pFlyFormat);
1613 RndStdIds ProcessEscherAlign(SvxMSDffImportRec* pRecord, WW8_FSPA *pFSPA,
1614 SfxItemSet &rFlySet);
1615 bool MiserableRTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
1616 sal_Int16 eHoriOri, sal_Int16 eHoriRel);
1617 SwFrameFormat* Read_GrafLayer( tools::Long nGrafAnchorCp );
1618 SwFlyFrameFormat* ImportReplaceableDrawables( SdrObject* &rpObject,
1619 SdrObject* &rpOurNewObject, SvxMSDffImportRec* pRecord, WW8_FSPA *pF,
1620 SfxItemSet &rFlySet );
1621 SwFlyFrameFormat *ConvertDrawTextToFly( SdrObject* &rpObject,
1622 SdrObject* &rpOurNewObject, SvxMSDffImportRec const * pRecord,
1623 RndStdIds eAnchor, WW8_FSPA const *pF, SfxItemSet &rFlySet );
1624 SwFrameFormat* MungeTextIntoDrawBox(SvxMSDffImportRec *pRecord,
1625 tools::Long nGrafAnchorCp, SwFrameFormat *pRetFrameFormat);
1627 void GrafikCtor();
1628 void GrafikDtor();
1630 // other stuff
1631 OUString GetFieldResult( WW8FieldDesc const * pF );
1632 void MakeTagString( OUString& rStr, const OUString& rOrg );
1633 void UpdateFields();
1634 OUString ConvertFFileName(const OUString& rRaw);
1635 WW8_CP Read_F_Tag(WW8FieldDesc* pF);
1636 void InsertTagField( const sal_uInt16 nId, const OUString& rTagText );
1637 tools::Long ImportExtSprm(WW8PLCFManResult* pRes);
1638 void EndExtSprm(sal_uInt16 nSprmId);
1639 void ReadDocInfo();
1641 // Ver8 lists
1643 void RegisterNumFormatOnTextNode(sal_uInt16 nCurrentLFO, sal_uInt8 nCurrentLevel,
1644 const bool bSetAttr = true);
1646 void RegisterNumFormatOnStyle(sal_uInt16 nStyle);
1647 void SetStylesList(sal_uInt16 nStyle, sal_uInt16 nCurrentLFO,
1648 sal_uInt8 nCurrentLevel);
1649 void RegisterNumFormat(sal_uInt16 nCurrentLFO, sal_uInt8 nCurrentLevel);
1651 // to be replaced by calls in the appropriate extended SvxMSDffManager
1653 const OUString* GetAnnotationAuthor(sal_uInt16 nIdx);
1655 void GetSmartTagInfo(SwFltRDFMark& rMark);
1657 // interfaces for the toggle attributes
1658 void SetToggleAttr(sal_uInt8 nAttrId, bool bOn);
1659 void SetToggleBiDiAttr(sal_uInt8 nAttrId, bool bOn);
1660 void ChkToggleAttr_( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask );
1662 void ChkToggleAttr( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask )
1664 if( nOldStyle81Mask != nNewStyle81Mask &&
1665 m_xCtrlStck->GetToggleAttrFlags() )
1666 ChkToggleAttr_( nOldStyle81Mask, nNewStyle81Mask );
1669 void ChkToggleBiDiAttr_( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask );
1671 void ChkToggleBiDiAttr( sal_uInt16 nOldStyle81Mask, sal_uInt16 nNewStyle81Mask )
1673 if( nOldStyle81Mask != nNewStyle81Mask &&
1674 m_xCtrlStck->GetToggleBiDiAttrFlags() )
1675 ChkToggleBiDiAttr_( nOldStyle81Mask, nNewStyle81Mask );
1678 void PopTableDesc();
1679 void MoveInsideFly(const SwFrameFormat *pFlyFormat);
1680 SwTwips MoveOutsideFly(SwFrameFormat *pFlyFormat, const SwPosition &rPos,
1681 bool bTableJoin = true);
1683 void SetOutlineStyles();
1685 bool SetSpacing(SwPaM &rMyPam, int nSpace, bool bIsUpper);
1686 bool SetUpperSpacing(SwPaM &pMyPam, int nSpace);
1687 bool SetLowerSpacing(SwPaM &rMyPam, int nSpace);
1689 bool IsInlineEscherHack() const
1690 { return !m_aFieldStack.empty() && m_aFieldStack.back().mnFieldId == 95; };
1692 void StoreMacroCmds();
1694 // #i84783#
1695 // determine object attribute "Layout in Table Cell"
1696 bool IsObjectLayoutInTableCell( const sal_uInt32 nLayoutInTableCell ) const;
1697 void ReadGlobalTemplateSettings( const OUString& sCreatedFrom, const css::uno::Reference< css::container::XNameContainer >& xPrjNameMap );
1698 SwWW8ImplReader(const SwWW8ImplReader &) = delete;
1699 SwWW8ImplReader& operator=(const SwWW8ImplReader&) = delete;
1700 public: // really private, but can only be done public
1701 ~SwWW8ImplReader();
1702 sal_uInt16 GetToggleAttrFlags() const;
1703 sal_uInt16 GetToggleBiDiAttrFlags() const;
1704 void SetToggleAttrFlags(sal_uInt16 nFlags);
1705 void SetToggleBiDiAttrFlags(sal_uInt16 nFlags);
1706 WW8_CP GetCurrAttrCP() const {return m_aCurrAttrCP;}
1707 bool IsParaEndInCPs(sal_Int32 , sal_Int32,bool bSdOD=true) const;
1708 //Clear the para end position recorded in reader intermittently for the least impact on loading performance
1709 void ClearParaEndPosition();
1711 tools::Long Read_Footnote(WW8PLCFManResult* pRes);
1712 sal_uInt16 End_Footnote();
1713 tools::Long Read_Field(WW8PLCFManResult* pRes);
1714 sal_uInt16 End_Field();
1715 tools::Long Read_Book(WW8PLCFManResult*);
1716 tools::Long Read_And(WW8PLCFManResult* pRes);
1717 tools::Long Read_AtnBook(WW8PLCFManResult*);
1718 tools::Long Read_FactoidBook(WW8PLCFManResult*);
1720 // attributes
1722 void Read_Special(sal_uInt16, const sal_uInt8*, short nLen);
1723 void Read_Obj(sal_uInt16, const sal_uInt8*, short nLen);
1724 void Read_PicLoc(sal_uInt16, const sal_uInt8* pData, short nLen );
1725 void Read_BoldUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
1726 void Read_Bidi(sal_uInt16 nId, const sal_uInt8*, short nLen);
1727 void Read_BoldBiDiUsw(sal_uInt16 nId, const sal_uInt8*, short nLen);
1728 void Read_AmbiguousSPRM(sal_uInt16 nId, const sal_uInt8*, short nLen);
1729 void Read_SubSuper( sal_uInt16, const sal_uInt8*, short nLen );
1730 bool ConvertSubToGraphicPlacement();
1731 static SwFrameFormat *ContainsSingleInlineGraphic(const SwPaM &rRegion);
1732 void Read_SubSuperProp( sal_uInt16, const sal_uInt8*, short nLen );
1733 void Read_Underline( sal_uInt16, const sal_uInt8*, short nLen );
1734 void Read_TextColor( sal_uInt16, const sal_uInt8*, short nLen );
1735 void openFont(sal_uInt16 nFCode, sal_uInt16 nId);
1736 void closeFont(sal_uInt16 nId);
1737 void Read_FontCode( sal_uInt16, const sal_uInt8*, short nLen );
1738 void Read_FontSize( sal_uInt16, const sal_uInt8*, short nLen );
1739 void Read_CharSet(sal_uInt16 , const sal_uInt8* pData, short nLen);
1740 void Read_Language( sal_uInt16, const sal_uInt8*, short nLen );
1741 void Read_CColl( sal_uInt16, const sal_uInt8*, short nLen );
1742 void Read_Kern( sal_uInt16, const sal_uInt8* pData, short nLen );
1743 void Read_FontKern( sal_uInt16, const sal_uInt8* pData, short nLen );
1744 void Read_Emphasis( sal_uInt16, const sal_uInt8* pData, short nLen );
1745 void Read_ScaleWidth( sal_uInt16, const sal_uInt8* pData, short nLen );
1746 void Read_Relief( sal_uInt16, const sal_uInt8* pData, short nLen);
1747 void Read_TextAnim( sal_uInt16, const sal_uInt8* pData, short nLen);
1749 void Read_NoLineNumb( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1751 void Read_LR( sal_uInt16 nId, const sal_uInt8*, short nLen );
1752 void Read_UL( sal_uInt16 nId, const sal_uInt8*, short nLen );
1753 void Read_ParaAutoBefore(sal_uInt16 , const sal_uInt8 *pData, short nLen);
1754 void Read_ParaAutoAfter(sal_uInt16 , const sal_uInt8 *pData, short nLen);
1755 void Read_ParaContextualSpacing( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1756 void Read_LineSpace( sal_uInt16, const sal_uInt8*, short nLen );
1758 void SetRelativeJustify( bool bRel );
1759 bool IsRelativeJustify();
1760 bool IsRelativeJustify(sal_uInt16 nColl, o3tl::sorted_vector<sal_uInt16>& rVisitedStyles);
1761 void Read_Justify(sal_uInt16, const sal_uInt8*, short nLen);
1763 void Read_IdctHint(sal_uInt16, const sal_uInt8*, short nLen);
1764 bool IsRightToLeft();
1765 void Read_RTLJustify(sal_uInt16, const sal_uInt8*, short nLen);
1766 void Read_Hyphenation( sal_uInt16, const sal_uInt8* pData, short nLen );
1767 void Read_WidowControl( sal_uInt16, const sal_uInt8* pData, short nLen );
1768 void Read_AlignFont( sal_uInt16, const sal_uInt8* pData, short nLen );
1769 void Read_UsePgsuSettings( sal_uInt16, const sal_uInt8* pData, short nLen );
1770 void Read_KeepLines( sal_uInt16, const sal_uInt8* pData, short nLen );
1771 void Read_KeepParas( sal_uInt16, const sal_uInt8* pData, short nLen );
1772 void Read_BreakBefore( sal_uInt16, const sal_uInt8* pData, short nLen );
1773 void Read_ApoPPC(sal_uInt16, const sal_uInt8* pData, short);
1775 void Read_BoolItem( sal_uInt16 nId, const sal_uInt8*, short nLen );
1777 void Read_Border( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1778 void Read_CharBorder(sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1779 void Read_Tab( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1780 void Read_Symbol(sal_uInt16, const sal_uInt8* pData, short nLen);
1781 void Read_FieldVanish( sal_uInt16 nId, const sal_uInt8* pData, short nLen );
1783 // Revision Marks ( == Redlining )
1785 // insert or delete content (change char attributes resp.)
1786 void Read_CRevisionMark(RedlineType eType, const sal_uInt8* pData, short nLen);
1787 // insert new content
1788 void Read_CFRMark(sal_uInt16 , const sal_uInt8* pData, short nLen);
1789 // delete old content
1790 void Read_CFRMarkDel(sal_uInt16 , const sal_uInt8* pData, short nLen);
1791 // change properties of content (e.g. char formatting)
1792 void Read_CPropRMark(sal_uInt16 , const sal_uInt8* pData, short nLen); // complex!
1794 void Read_TabRowEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
1795 void Read_TabCellEnd( sal_uInt16, const sal_uInt8* pData, short nLen );
1796 bool ParseTabPos(WW8_TablePos *aTabPos, WW8PLCFx_Cp_FKP* pPap);
1797 void Read_Shade( sal_uInt16, const sal_uInt8* pData, short nLen );
1798 void Read_ANLevelNo( sal_uInt16, const sal_uInt8* pData, short nLen );
1799 void Read_ANLevelDesc( sal_uInt16, const sal_uInt8* pData, short nLen );
1801 // outline level Ver8
1802 void Read_POutLvl(sal_uInt16, const sal_uInt8* pData, short nLen);
1804 void Read_OLST( sal_uInt16, const sal_uInt8* pData, short nLen );
1806 void Read_CharShadow( sal_uInt16, const sal_uInt8* pData, short nLen );
1807 void Read_CharHighlight( sal_uInt16, const sal_uInt8* pData, short nLen );
1808 // Ver8-Listen
1810 void Read_ListLevel( sal_uInt16 nId, const sal_uInt8* pData, short nLen);
1813 * read and interpret the sprmPIlfo used to determine which list
1814 * contains the paragraph.
1815 * @param nId unused (sprm value, 0x460b for sprmPIlfo).
1816 * @param[in] pData operand.
1817 * @param[in] nLen size of the operand (pData) in byte, should be 2.
1818 * -1 to indicate the actual level is finished.
1820 void Read_LFOPosition( sal_uInt16 nId, const sal_uInt8* pData, short nLen);
1821 bool SetTextFormatCollAndListLevel(const SwPaM& rRg, SwWW8StyInf& rStyleInfo);
1823 void Read_StyleCode(sal_uInt16, const sal_uInt8* pData, short nLen);
1824 void Read_Majority(sal_uInt16, const sal_uInt8* , short );
1825 void Read_DoubleLine_Rotate( sal_uInt16, const sal_uInt8* pDATA, short nLen);
1827 void Read_TextForeColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1828 void Read_TextBackColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1829 void Read_ParaBackColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1830 void Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nLen);
1831 static Color ExtractColour(const sal_uInt8* &rpData, bool bVer67);
1833 void Read_TextVerticalAdjustment(sal_uInt16, const sal_uInt8* pData, short nLen);
1834 void Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, short nLen);
1835 tools::Long MapBookmarkVariables(const WW8FieldDesc* pF, OUString &rOrigName,
1836 const OUString &rData);
1837 OUString GetMappedBookmark(const OUString &rOrigName);
1839 // fields
1840 eF_ResT Read_F_Input(WW8FieldDesc*, OUString& rStr);
1841 eF_ResT Read_F_InputVar(WW8FieldDesc*, OUString& rStr);
1842 eF_ResT Read_F_ANumber( WW8FieldDesc*, OUString& );
1843 eF_ResT Read_F_DocInfo( WW8FieldDesc* pF, OUString& rStr );
1844 eF_ResT Read_F_Author( WW8FieldDesc*, OUString& );
1845 eF_ResT Read_F_TemplName( WW8FieldDesc*, OUString& );
1846 SvNumFormatType GetTimeDatePara(OUString const & rStr, sal_uInt32& rFormat, LanguageType &rLang,
1847 int nWhichDefault, bool bHijri = false);
1848 bool ForceFieldLanguage(SwField &rField, LanguageType nLang);
1849 eF_ResT Read_F_DateTime( WW8FieldDesc*, OUString& rStr );
1850 eF_ResT Read_F_FileName( WW8FieldDesc*, OUString& rStr);
1851 eF_ResT Read_F_Num( WW8FieldDesc* pF, OUString& );
1852 eF_ResT Read_F_CurPage( WW8FieldDesc*, OUString& );
1853 eF_ResT Read_F_Ref( WW8FieldDesc* pF, OUString& );
1855 eF_ResT Read_F_Set( WW8FieldDesc*, OUString& rStr );
1856 eF_ResT Read_F_PgRef( WW8FieldDesc*, OUString& rStr );
1857 eF_ResT Read_F_NoteReference( WW8FieldDesc* pF, OUString& rStr );
1859 eF_ResT Read_F_Tox( WW8FieldDesc* pF, OUString& rStr );
1860 eF_ResT Read_F_Symbol( WW8FieldDesc*, OUString& rStr );
1861 eF_ResT Read_F_Embedd( WW8FieldDesc*, OUString& rStr );
1862 eF_ResT Read_F_FormTextBox( WW8FieldDesc* pF, OUString& rStr);
1863 eF_ResT Read_F_FormCheckBox( WW8FieldDesc* pF, OUString& rStr );
1864 eF_ResT Read_F_FormListBox( WW8FieldDesc* pF, OUString& rStr);
1865 css::awt::Size MiserableDropDownFormHack(const OUString &rString,
1866 css::uno::Reference<css::beans::XPropertySet> const & rPropSet);
1868 eF_ResT Read_F_Macro( WW8FieldDesc*, OUString& rStr);
1869 eF_ResT Read_F_DBField( WW8FieldDesc*, OUString& rStr );
1870 eF_ResT Read_F_DBNext( WW8FieldDesc*, OUString& );
1871 eF_ResT Read_F_DBNum( WW8FieldDesc*, OUString& );
1872 eF_ResT Read_F_Equation( WW8FieldDesc*, OUString& );
1873 void Read_SubF_Ruby( msfilter::util::WW8ReadFieldParams& rReadParam);
1874 eF_ResT Read_F_IncludePicture( WW8FieldDesc*, OUString& rStr );
1875 eF_ResT Read_F_IncludeText( WW8FieldDesc*, OUString& rStr );
1876 eF_ResT Read_F_Seq( WW8FieldDesc*, OUString& rStr );
1877 /// Reads a STYLEREF field.
1878 eF_ResT Read_F_Styleref(WW8FieldDesc*, OUString& rStr);
1880 eF_ResT Read_F_OCX(WW8FieldDesc*, OUString&);
1881 eF_ResT Read_F_Hyperlink(WW8FieldDesc*, OUString& rStr);
1882 eF_ResT Read_F_Shape(WW8FieldDesc* pF, OUString& rStr);
1883 eF_ResT Read_F_HTMLControl( WW8FieldDesc* pF, OUString& rStr);
1885 short ImportSprm(const sal_uInt8* pPos, sal_Int32 nMemLen, sal_uInt16 nId = 0);
1887 bool SearchRowEnd(WW8PLCFx_Cp_FKP* pPap,WW8_CP &rStartCp, int nLevel) const;
1888 /// Seek to the end of the table with pPap, returns true on success.
1889 bool SearchTableEnd(WW8PLCFx_Cp_FKP* pPap) const;
1890 bool FloatingTableConversion(WW8PLCFx_Cp_FKP* pPap);
1892 const WW8Fib& GetFib() const { return *m_xWwFib; }
1893 SwDoc& GetDoc() const { return m_rDoc; }
1894 sal_uInt16 GetCurrentColl() const { return m_nCurrentColl; }
1895 void SetNCurrentColl( sal_uInt16 nColl ) { m_nCurrentColl = nColl; }
1896 std::unique_ptr<SfxItemSet> SetCurrentItemSet(std::unique_ptr<SfxItemSet> pItemSet);
1897 sal_uInt16 StyleUsingLFO( sal_uInt16 nLFOIndex ) const ;
1898 const SwFormat* GetStyleWithOrgWWName( OUString const & rName ) const ;
1900 static bool GetPictGrafFromStream(Graphic& rGraphic, SvStream& rSrc);
1901 static void PicRead( SvStream *pDataStream, WW8_PIC *pPic, bool bVer67);
1902 static bool ImportOleWMF(const tools::SvRef<SotStorage>& xSrc1, GDIMetaFile& rWMF, tools::Long& rX,
1903 tools::Long& rY);
1904 static Color GetCol(sal_uInt8 nIco);
1906 SwWW8ImplReader( sal_uInt8 nVersionPara, SotStorage* pStorage, SvStream* pSt,
1907 SwDoc& rD, const OUString& rBaseURL, bool bNewDoc, bool bSkipImages, SwPosition const &rPos );
1909 const OUString& GetBaseURL() const { return m_sBaseURL; }
1910 // load a complete doc file
1911 ErrCode LoadDoc(WW8Glossary *pGloss=nullptr);
1912 rtl_TextEncoding GetCurrentCharSet();
1913 rtl_TextEncoding GetCurrentCJKCharSet();
1914 rtl_TextEncoding GetCharSetFromLanguage();
1915 rtl_TextEncoding GetCJKCharSetFromLanguage();
1917 void PostProcessAttrs();
1918 void ReadEmbeddedData(SvStream& rStrm, SwDocShell const * pDocShell, struct HyperLinksTable& hlStr);
1919 void NotifyMacroEventRead();
1922 bool CanUseRemoteLink(const OUString &rGrfName);
1923 void UseListIndent(SwWW8StyInf &rStyle, const SwNumFormat &rFormat);
1924 void SetStyleIndent(SwWW8StyInf &rStyleInfo, const SwNumFormat &rFormat);
1925 // #i103711#
1926 // #i105414#
1927 void SyncIndentWithList( SvxLRSpaceItem &rLR,
1928 const SwNumFormat &rFormat,
1929 const bool bFirstLineOfStSet,
1930 const bool bLeftIndentSet );
1931 tools::Long GetListFirstLineIndent(const SwNumFormat &rFormat);
1932 OUString BookmarkToWriter(const OUString &rBookmark);
1933 bool RTLGraphicsHack(SwTwips &rLeft, SwTwips nWidth,
1934 sal_Int16 eHoriOri, sal_Int16 eHoriRel, SwTwips nPageLeft,
1935 SwTwips nPageRight, SwTwips nPageSize);
1936 void MatchEscherMirrorIntoFlySet(const SvxMSDffImportRec &rRecord,
1937 SfxItemSet &rFlySet);
1938 #endif
1940 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */