LibreOffice Module sw (master)  1
ww8par2.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #ifndef INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR2_HXX
21 #define INCLUDED_SW_SOURCE_FILTER_WW8_WW8PAR2_HXX
22 
23 #include <swtypes.hxx>
24 #include <fmtfsize.hxx>
25 #include <fmtornt.hxx>
26 #include <fmtsrnd.hxx>
27 #include <editeng/lrspitem.hxx>
28 #include <svl/itemset.hxx>
29 #include <svx/swframetypes.hxx>
30 #include <swtable.hxx>
31 
32 #include "ww8scan.hxx"
33 #include "ww8par.hxx"
34 
35 class WW8RStyle;
36 
38 {
39 public:
41  void Insert(const SwPosition &rPos);
42 private:
43  WW8DupProperties(const WW8DupProperties&) = delete;
47 };
48 
50 {
52 
53  // part 1: directly derived Sw attributes
54  sal_Int16 nXPos, nYPos; // Position
55  sal_Int16 nLeMgn, nRiMgn; // borders
56  sal_Int16 nUpMgn, nLoMgn; // borders
57  sal_Int16 nWidth, nHeight; // size
58  sal_Int16 nNetWidth;
59 
60  SwFrameSize eHeightFix; // height fixed or min
61  static constexpr RndStdIds eAnchor = RndStdIds::FLY_AT_PARA; // binding
62  short eHRel; // page or page border
63  short eVRel; // page or page border
64  sal_Int16 eVAlign; // up, down, centered
65  sal_Int16 eHAlign; // left, right, centered
66  css::text::WrapTextMode
67  eSurround; // wrap mode
68 
69  sal_uInt8 nXBind, nYBind; // bound relative to what
70 
71  // part 2: changes found during reading
73  std::unique_ptr<SwPosition> xMainTextPos; // to return to main text after apo
74  sal_uInt16 nLineSpace; // line space in tw for graf apos
75  bool bAutoWidth;
76  bool bToggelPos;
77 
78  // add parameter <nWWPgTop> - WW8's page top margin
79  WW8SwFlyPara( SwPaM& rPaM,
80  SwWW8ImplReader& rIo,
81  WW8FlyPara& rWW,
82  const sal_uInt32 nWWPgTop,
83  const sal_uInt32 nPgWidth,
84  const sal_Int32 nIniFlyDx,
85  const sal_Int32 nIniFlyDy );
86 
87  void BoxUpWidth( long nWidth );
88  std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
89 };
90 
91 class WW8RStyle: public WW8Style
92 {
93 friend class SwWW8ImplReader;
95  SwWW8ImplReader* mpIo; // parser class
96  SvStream* mpStStrm; // input file
97 
98  SwNumRule* mpStyRule; // bullets and enumerations in styles
99 
100  sal_uInt8* mpParaSprms; // all ParaSprms of the UPX if UPX.Papx
101  sal_uInt16 mnSprmsLen; // its length
102 
103  sal_uInt8 mnWwNumLevel; // for bullets and enumerations in styles
104 
106  bool mbFontChanged; // For Simulating Default-Font
107  bool mbCJKFontChanged; // For Simulating Default-CJK Font
108  bool mbCTLFontChanged; // For Simulating Default-CTL Font
109  bool mbFSizeChanged; // For Simulating Default-FontSize
110  bool mbFCTLSizeChanged; // For Simulating Default-CTL FontSize
111  bool mbWidowsChanged; // For Simulating Default-Widows / Orphans
112 
113  void ImportSprms(std::size_t nPosFc, short nLen, bool bPap);
114  void ImportSprms(sal_uInt8 *pSprms, short nLen, bool bPap);
115  void ImportGrupx(short nLen, bool bPara, bool bOdd);
116  short ImportUPX(short nLen, bool bPAP, bool bOdd);
117 
118  void Set1StyleDefaults();
119  void Import1Style(sal_uInt16 nNr);
120  void RecursiveReg(sal_uInt16 nNr);
121 
122  void ImportNewFormatStyles();
123  void ScanStyles();
124  void ImportOldFormatStyles();
125 
126  bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
127  void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
128 
129  WW8RStyle(const WW8RStyle&) = delete;
130  WW8RStyle& operator=(const WW8RStyle&) = delete;
131 public:
132  WW8RStyle( WW8Fib& rFib, SwWW8ImplReader* pI );
133  void Import();
134  void PostProcessStyles();
135  SprmResult HasParaSprm(sal_uInt16 nId) const;
136 };
137 
138 class WW8FlySet: public SfxItemSet
139 {
140 private:
141  const WW8FlySet& operator=(const WW8FlySet&) = delete;
142  void Init(const SwWW8ImplReader& rReader, const SwPaM* pPaM);
143 public:
144  WW8FlySet(SwWW8ImplReader& rReader, const WW8FlyPara* pFW,
145  const WW8SwFlyPara* pFS, bool bGraf);
146  WW8FlySet(SwWW8ImplReader& rReader, const SwPaM* pPaM, const WW8_PIC& rPic,
147  long nWidth, long nHeight);
148 };
149 
150 // Gets filled in WW8TabDesc::MergeCells().
151 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
153 {
154 private:
155  std::vector<std::vector<SwTableBox*> > m_vRows;
156 
157  WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
158  WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
159 
160 public:
162  short nGroupWidth;
164 
165  WW8SelBoxInfo(short nXCenter, short nWidth)
166  : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
167  {}
168 
169  size_t size() const
170  {
171  size_t nResult = 0;
172  for (auto& it : m_vRows)
173  nResult += it.size();
174  return nResult;
175  }
176 
177  size_t rowsCount() const { return m_vRows.size(); }
178 
179  const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
180 
181  void push_back( SwTableBox* pBox )
182  {
183  bool bDone = false;
184  for (auto& iRow : m_vRows)
185  if (iRow[0]->GetUpper() == pBox->GetUpper())
186  {
187  iRow.push_back(pBox);
188  bDone = true;
189  break;
190  }
191  if (!bDone)
192  {
193  const size_t sz = m_vRows.size();
194  m_vRows.resize(sz+1);
195  m_vRows[sz].push_back(pBox);
196  }
197  }
198 };
199 
201 {
202  std::vector<OUString> m_aNumRuleNames;
203  std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
204 
206 
209 
210  std::unique_ptr<SwPosition> m_xTmpPos;
211 
212  SwTableNode* m_pTableNd; // table node
213  const SwTableLines* m_pTabLines; // row array of node
214  SwTableLine* m_pTabLine; // current row
215  SwTableBoxes* m_pTabBoxes; // boxes array in current row
216  SwTableBox* m_pTabBox; // current cell
217 
218  std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
219 
221 
222  short m_nRows;
224  short m_nBands;
225  short m_nMinLeft;
227  short m_nMaxRight;
228  short m_nSwWidth;
231 
232  bool m_bOk;
234  sal_Int16 m_eOri;
235  bool m_bIsBiDi;
236  // 2. common admin info
238  short m_nCurrentBandRow; // SW: row of current band
239  // 3. admin info for writer
241 
242  sal_uInt16 m_nRowsToRepeat;
243 
244  // 4. methods
245 
246  sal_uInt16 GetLogicalWWCol() const;
247  void SetTabBorders( SwTableBox* pBox, short nIdx );
248  void SetTabShades( SwTableBox* pBox, short nWwIdx );
249  void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
250  void SetTabDirection( SwTableBox* pBox, short nWwIdx );
251  void CalcDefaults();
252  void SetPamInCell(short nWwCol, bool bPam);
253  void InsertCells( short nIns );
254  void AdjustNewBand();
255 
256  WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
257 
258  // single box - maybe used in a merge group
259  // (the merge groups are processed later at once)
260  void UpdateTableMergeGroup(WW8_TCell const & rCell,
261  WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
262 
263  WW8TabDesc(WW8TabDesc const&) = delete;
264  WW8TabDesc& operator=(WW8TabDesc const&) = delete;
265 
266 public:
267  const SwTable* m_pTable; // table
271  bool IsValidCell(short nCol) const;
272  bool InFirstParaInCell() const;
273 
274  WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
275  bool Ok() const { return m_bOk; }
276  void CreateSwTable();
277  void UseSwTable();
278  void SetSizePosition(SwFrameFormat* pFrameFormat);
279  void TableCellEnd();
280  void MoveOutsideTable();
281  void ParkPaM();
282  void FinishSwTable();
283  void MergeCells();
284  short GetMinLeft() const { return m_nConvertedLeft; }
285  ~WW8TabDesc();
286 
287  const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
288  short GetCurrentCol() const { return m_nCurrentCol; }
289  // find name of numrule valid for current WW-COL
290  OUString GetNumRuleName() const;
291  void SetNumRuleName( const OUString& rName );
292 
293  sw::util::RedlineStack* getOldRedlineStack() { return mxOldRedlineStack.get(); }
294 };
295 
297 
298 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo);
299 #endif
300 
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:61
Marks a position in the document model.
Definition: pam.hxx:35
short m_nPreferredWidth
Definition: ww8par2.hxx:229
short m_nCurrentBandRow
Definition: ww8par2.hxx:238
sal_Int16 nYPos
Definition: ww8par2.hxx:54
void SetTabBorders(SwTableBox *pBox, short nIdx)
Definition: ww8par2.cxx:3008
void CalcDefaults()
Definition: ww8par2.cxx:2127
void MergeCells()
Definition: ww8par2.cxx:2571
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:293
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2212
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:101
Definition: doc.hxx:185
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:67
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:203
SfxItemSet aChrSet
Definition: ww8par2.hxx:46
WW8SelBoxInfo & operator=(WW8SelBoxInfo const &)=delete
SwFlyFrameFormat * m_pFlyFormat
Definition: ww8par2.hxx:269
WW8RStyle & operator=(const WW8RStyle &)=delete
void SetTabShades(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3063
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
WW8LvlType
Definition: ww8par2.hxx:296
WW8SwFlyPara(SwPaM &rPaM, SwWW8ImplReader &rIo, WW8FlyPara &rWW, const sal_uInt32 nWWPgTop, const sal_uInt32 nPgWidth, const sal_Int32 nIniFlyDx, const sal_Int32 nIniFlyDy)
Definition: ww8par6.cxx:1860
sal_uInt8 nYBind
Definition: ww8par2.hxx:69
bool Ok() const
Definition: ww8par2.hxx:275
SwWW8FltControlStack * pCtrlStck
Definition: ww8par2.hxx:45
void SetTabDirection(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3116
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:208
bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle)
Definition: ww8par2.cxx:3787
void ImportOldFormatStyles()
Definition: ww8par2.cxx:4260
sal_Int16 eHAlign
Definition: ww8par2.hxx:65
sal_Int16 nLeMgn
Definition: ww8par2.hxx:55
WW8TabBandDesc * m_pFirstBand
Definition: ww8par2.hxx:207
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:213
WW8TabDesc & operator=(WW8TabDesc const &)=delete
const SwTable * m_pTable
Definition: ww8par2.hxx:267
short m_nMaxRight
Definition: ww8par2.hxx:227
short GetCurrentCol() const
Definition: ww8par2.hxx:288
SwFlyFrameFormat * pFlyFormat
Definition: ww8par2.hxx:51
WW8TabDesc(WW8TabDesc const &)=delete
void SetPamInCell(short nWwCol, bool bPam)
Definition: ww8par2.cxx:2890
SvStream * mpStStrm
Definition: ww8par2.hxx:96
bool mbCJKFontChanged
Definition: ww8par2.hxx:107
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:155
SfxItemSet aParSet
Definition: ww8par2.hxx:46
sal_Int16 nHeight
Definition: ww8par2.hxx:57
short m_nBands
Definition: ww8par2.hxx:224
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2256
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:215
void Import()
Definition: ww8par2.cxx:4476
void MoveOutsideTable()
Definition: ww8par2.cxx:2742
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:88
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2868
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:74
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3709
short nGroupXStart
Definition: ww8par2.hxx:161
short m_nConvertedLeft
Definition: ww8par2.hxx:226
sal_Int16 nRiMgn
Definition: ww8par2.hxx:55
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2230
bool m_bIsBiDi
Definition: ww8par2.hxx:235
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwFrameSize eHeightFix
Definition: ww8par2.hxx:60
void AdjustNewBand()
Definition: ww8par2.cxx:3152
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4467
Style of a layout element.
Definition: frmfmt.hxx:57
void UpdateTableMergeGroup(WW8_TCell const &rCell, WW8SelBoxInfo *pActGroup, SwTableBox *pActBox, sal_uInt16 nCol)
Definition: ww8par2.cxx:3311
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3369
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:100
short m_nRows
Definition: ww8par2.hxx:222
bool mbFSizeChanged
Definition: ww8par2.hxx:109
sal_Int16 nWidth
Definition: ww8par2.hxx:57
void FinishSwTable()
Definition: ww8par2.cxx:2749
short m_nDefaultSwCols
Definition: ww8par2.hxx:223
short m_nPercentWidth
Definition: ww8par2.hxx:230
sal_uInt8 nXBind
Definition: ww8par2.hxx:69
WW8SelBoxInfo(WW8SelBoxInfo const &)=delete
sal_uInt16 GetLogicalWWCol() const
Definition: ww8par2.cxx:3346
short nGroupWidth
Definition: ww8par2.hxx:162
void CreateSwTable()
Definition: ww8par2.cxx:2391
sti
Definition: wwstyles.hxx:27
SwFrameSize
Definition: fmtfsize.hxx:35
bool bToggelPos
Definition: ww8par2.hxx:76
const WW8FlySet & operator=(const WW8FlySet &)=delete
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:205
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:214
std::unique_ptr< SwPosition > m_xTmpPos
Definition: ww8par2.hxx:210
sal_Int16 m_eOri
Definition: ww8par2.hxx:234
size_t rowsCount() const
Definition: ww8par2.hxx:177
bool mbTextColChanged
Definition: ww8par2.hxx:105
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:165
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
size_t size() const
Definition: ww8par2.hxx:169
bool mbFontChanged
Definition: ww8par2.hxx:106
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:218
void ScanStyles()
Definition: ww8par2.cxx:4001
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:202
sal_Int32 WW8_CP
Definition: ww8struc.hxx:151
bool mbCTLFontChanged
Definition: ww8par2.hxx:108
std::unique_ptr< SwPosition > xMainTextPos
Definition: ww8par2.hxx:73
bool bGroupLocked
Definition: ww8par2.hxx:163
wwSprmParser maSprmParser
Definition: ww8par2.hxx:94
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3599
bool bAutoWidth
Definition: ww8par2.hxx:75
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3665
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
bool m_bClaimLineFormat
Definition: ww8par2.hxx:233
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:212
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:179
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2875
unsigned char sal_uInt8
sal_Int16 eVAlign
Definition: ww8par2.hxx:64
short m_nSwWidth
Definition: ww8par2.hxx:228
SwNumRule * mpStyRule
Definition: ww8par2.hxx:98
short GetMinLeft() const
Definition: ww8par2.hxx:284
SfxItemSet m_aItemSet
Definition: ww8par2.hxx:270
wwSprmParser knows how to take a sequence of bytes and split it up into sprms and their arguments ...
Definition: ww8scan.hxx:120
WW8_TCell * m_pCurrentWWCell
Definition: ww8par2.hxx:220
sal_Int16 nXPos
Definition: ww8par2.hxx:54
bool m_bOk
Definition: ww8par2.hxx:232
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:216
void TableCellEnd()
Definition: ww8par2.cxx:3257
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
FIB - the File Information Block.
Definition: ww8scan.hxx:1106
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:874
void ParkPaM()
Definition: ww8par2.cxx:2707
sal_uInt16 m_nRowsToRepeat
Definition: ww8par2.hxx:242
bool mbFCTLSizeChanged
Definition: ww8par2.hxx:110
sal_Int16 nUpMgn
Definition: ww8par2.hxx:56
SwPosition * m_pParentPos
Definition: ww8par2.hxx:268
void Import1Style(sal_uInt16 nNr)
Definition: ww8par2.cxx:3893
void SetTabVertAlign(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3124
long nNewNetWidth
Definition: ww8par2.hxx:72
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3869
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3632
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3361
RndStdIds
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:103
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:95
void BoxUpWidth(long nWidth)
Definition: ww8par6.cxx:2114
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2365
short eHRel
Definition: ww8par2.hxx:62
const WW8_TCell * GetCurrentWWCell() const
Definition: ww8par2.hxx:287
void RecursiveReg(sal_uInt16 nNr)
Definition: ww8par2.cxx:3948
short m_nMinLeft
Definition: ww8par2.hxx:225
sal_Int16 nLoMgn
Definition: ww8par2.hxx:56
void PostProcessStyles()
Definition: ww8par2.cxx:3971
void UseSwTable()
Definition: ww8par2.cxx:2542
SwTableLine * GetUpper()
Definition: swtable.hxx:421
void Set1StyleDefaults()
Definition: ww8par2.cxx:3743
short eVRel
Definition: ww8par2.hxx:63
bool mbWidowsChanged
Definition: ww8par2.hxx:111
short m_nCurrentCol
Definition: ww8par2.hxx:240
void push_back(SwTableBox *pBox)
Definition: ww8par2.hxx:181
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2815
short m_nCurrentRow
Definition: ww8par2.hxx:237
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2123
WW8DupProperties & operator=(const WW8DupProperties &)=delete
void InsertCells(short nIns)
Definition: ww8par2.cxx:2996
WW8RStyle(const WW8RStyle &)=delete
sal_Int16 nNetWidth
Definition: ww8par2.hxx:58