nss: upgrade to release 3.73
[LibreOffice.git] / sw / source / filter / ww8 / ww8par2.hxx
blobac35b4813b8ff841a2ef10e756a1e742b176b777
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_WW8PAR2_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR2_HXX
23 #include <fmtfsize.hxx>
24 #include <svl/itemset.hxx>
25 #include <svx/swframetypes.hxx>
26 #include <swtable.hxx>
28 #include "ww8scan.hxx"
29 #include "ww8par.hxx"
31 class WW8RStyle;
33 class WW8DupProperties
35 public:
36 WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack);
37 void Insert(const SwPosition &rPos);
38 private:
39 WW8DupProperties(const WW8DupProperties&) = delete;
40 WW8DupProperties& operator=(const WW8DupProperties&) = delete;
41 SwWW8FltControlStack* pCtrlStck;
42 SfxItemSet aChrSet,aParSet;
45 struct WW8SwFlyPara
47 SwFlyFrameFormat* pFlyFormat;
49 // part 1: directly derived Sw attributes
50 sal_Int16 nXPos, nYPos; // Position
51 sal_Int16 nLeMgn, nRiMgn; // borders
52 sal_Int16 nUpMgn, nLoMgn; // borders
53 sal_Int16 nWidth, nHeight; // size
54 sal_Int16 nNetWidth;
56 SwFrameSize eHeightFix; // height fixed or min
57 static constexpr RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; // binding
58 short eHRel; // page or page border
59 short eVRel; // page or page border
60 sal_Int16 eVAlign; // up, down, centered
61 sal_Int16 eHAlign; // left, right, centered
62 css::text::WrapTextMode
63 eSurround; // wrap mode
65 sal_uInt8 nXBind, nYBind; // bound relative to what
67 // part 2: changes found during reading
68 tools::Long nNewNetWidth;
69 std::unique_ptr<SwPosition> xMainTextPos; // to return to main text after apo
70 sal_uInt16 nLineSpace; // line space in tw for graf apos
71 bool bAutoWidth;
72 bool bTogglePos;
74 // add parameter <nWWPgTop> - WW8's page top margin
75 WW8SwFlyPara( SwPaM& rPaM,
76 SwWW8ImplReader& rIo,
77 WW8FlyPara& rWW,
78 const sal_uInt32 nWWPgTop,
79 const sal_uInt32 nPgWidth,
80 const sal_Int32 nIniFlyDx,
81 const sal_Int32 nIniFlyDy );
83 void BoxUpWidth( tools::Long nWidth );
84 std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
87 class WW8RStyle: public WW8Style
89 friend class SwWW8ImplReader;
90 wwSprmParser maSprmParser;
91 SwWW8ImplReader* mpIo; // parser class
92 SvStream* mpStStrm; // input file
94 SwNumRule* mpStyRule; // bullets and enumerations in styles
96 sal_uInt8* mpParaSprms; // all ParaSprms of the UPX if UPX.Papx
97 sal_uInt16 mnSprmsLen; // its length
99 sal_uInt8 mnWwNumLevel; // for bullets and enumerations in styles
101 bool mbTextColChanged;
102 bool mbFontChanged; // For Simulating Default-Font
103 bool mbCJKFontChanged; // For Simulating Default-CJK Font
104 bool mbCTLFontChanged; // For Simulating Default-CTL Font
105 bool mbFSizeChanged; // For Simulating Default-FontSize
106 bool mbFCTLSizeChanged; // For Simulating Default-CTL FontSize
107 bool mbWidowsChanged; // For Simulating Default-Widows / Orphans
108 bool mbBidiChanged; // For Simulating Default-LTR
110 void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
111 void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
112 void ImportGrupx(short nLen, bool bPara, bool bOdd);
113 short ImportUPX(short nLen, bool bPAP, bool bOdd);
115 void Set1StyleDefaults();
116 void Import1Style(sal_uInt16 nNr);
117 void RecursiveReg(sal_uInt16 nNr);
119 void ImportNewFormatStyles();
120 void ScanStyles();
121 void ImportOldFormatStyles();
123 bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
124 void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
126 WW8RStyle(const WW8RStyle&) = delete;
127 WW8RStyle& operator=(const WW8RStyle&) = delete;
128 public:
129 WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
130 void Import();
131 void PostProcessStyles();
132 SprmResult HasParaSprm(sal_uInt16 nId) const;
135 class WW8FlySet: public SfxItemSet
137 private:
138 const WW8FlySet& operator=(const WW8FlySet&) = delete;
139 void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
140 public:
141 WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
142 const WW8SwFlyPara* pFS, bool bGraf);
143 WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
144 tools::Long nWidth, tools::Long nHeight);
147 // Gets filled in WW8TabDesc::MergeCells().
148 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
149 class WW8SelBoxInfo
151 private:
152 std::vector<std::vector<SwTableBox*> > m_vRows;
154 WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
155 WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
157 public:
158 short nGroupXStart;
159 short nGroupWidth;
160 bool bGroupLocked;
162 WW8SelBoxInfo(short nXCenter, short nWidth)
163 : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
166 size_t size() const
168 size_t nResult = 0;
169 for (auto& it : m_vRows)
170 nResult += it.size();
171 return nResult;
174 size_t rowsCount() const { return m_vRows.size(); }
176 const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
178 void push_back( SwTableBox* pBox )
180 bool bDone = false;
181 for (auto& iRow : m_vRows)
182 if (iRow[0]->GetUpper() == pBox->GetUpper())
184 iRow.push_back(pBox);
185 bDone = true;
186 break;
188 if (!bDone)
190 const size_t sz = m_vRows.size();
191 m_vRows.resize(sz+1);
192 m_vRows[sz].push_back(pBox);
197 class WW8TabDesc
199 std::vector<OUString> m_aNumRuleNames;
200 std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
202 SwWW8ImplReader* m_pIo;
204 WW8TabBandDesc* m_pFirstBand;
205 WW8TabBandDesc* m_pActBand;
207 std::unique_ptr<SwPosition> m_xTmpPos;
209 SwTableNode* m_pTableNd; // table node
210 const SwTableLines* m_pTabLines; // row array of node
211 SwTableLine* m_pTabLine; // current row
212 SwTableBoxes* m_pTabBoxes; // boxes array in current row
213 SwTableBox* m_pTabBox; // current cell
215 std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
217 WW8_TCell* m_pCurrentWWCell;
219 short m_nRows;
220 short m_nDefaultSwCols;
221 short m_nBands;
222 short m_nMinLeft;
223 short m_nMaxRight;
224 short m_nSwWidth;
225 short m_nPreferredWidth;
226 short m_nPercentWidth;
228 bool m_bOk;
229 bool m_bClaimLineFormat;
230 sal_Int16 m_eOri;
231 bool m_bIsBiDi;
232 // 2. common admin info
233 short m_nCurrentRow;
234 short m_nCurrentBandRow; // SW: row of current band
235 // 3. admin info for writer
236 short m_nCurrentCol;
238 sal_uInt16 m_nRowsToRepeat;
240 // 4. methods
242 sal_uInt16 GetLogicalWWCol() const;
243 void SetTabBorders( SwTableBox* pBox, short nIdx );
244 void SetTabShades( SwTableBox* pBox, short nWwIdx );
245 void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
246 void SetTabDirection( SwTableBox* pBox, short nWwIdx );
247 void CalcDefaults();
248 void SetPamInCell(short nWwCol, bool bPam);
249 void InsertCells( short nIns );
250 void AdjustNewBand();
252 WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
254 // single box - maybe used in a merge group
255 // (the merge groups are processed later at once)
256 void UpdateTableMergeGroup(WW8_TCell const & rCell,
257 WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
259 WW8TabDesc(WW8TabDesc const&) = delete;
260 WW8TabDesc& operator=(WW8TabDesc const&) = delete;
262 public:
263 const SwTable* m_pTable; // table
264 SwPosition* m_pParentPos;
265 SwFlyFrameFormat* m_pFlyFormat;
266 SfxItemSet m_aItemSet;
267 bool IsValidCell(short nCol) const;
268 bool InFirstParaInCell() const;
270 WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
271 bool Ok() const { return m_bOk; }
272 void CreateSwTable();
273 void UseSwTable();
274 void SetSizePosition(SwFrameFormat* pFrameFormat);
275 void TableCellEnd();
276 void MoveOutsideTable();
277 void ParkPaM();
278 void FinishSwTable();
279 void MergeCells();
280 short GetMinLeft() const { return m_nMinLeft; }
281 ~WW8TabDesc();
283 const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
284 short GetCurrentCol() const { return m_nCurrentCol; }
285 // find name of numrule valid for current WW-COL
286 OUString GetNumRuleName() const;
287 void SetNumRuleName( const OUString& rName );
289 sw::util::RedlineStack* getOldRedlineStack() { return mxOldRedlineStack.get(); }
292 enum WW8LvlType {WW8_None, WW8_Outline, WW8_Numbering, WW8_Sequence, WW8_Pause};
294 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo);
295 #endif
297 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */