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 <fmtfsize.hxx>
24 #include <svl/itemset.hxx>
25 #include <svx/swframetypes.hxx>
26 #include <swtable.hxx>
27 
28 #include "ww8scan.hxx"
29 #include "ww8par.hxx"
30 
31 class WW8RStyle;
32 
34 {
35 public:
37  void Insert(const SwPosition &rPos);
38 private:
39  WW8DupProperties(const WW8DupProperties&) = delete;
43 };
44 
46 {
48 
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;
55 
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
64 
65  sal_uInt8 nXBind, nYBind; // bound relative to what
66 
67  // part 2: changes found during reading
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 bToggelPos;
73 
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 );
82 
83  void BoxUpWidth( long nWidth );
84  std::unique_ptr<SwWW8FltAnchorStack> xOldAnchorStck;
85 };
86 
87 class WW8RStyle: public WW8Style
88 {
89 friend class SwWW8ImplReader;
91  SwWW8ImplReader* mpIo; // parser class
92  SvStream* mpStStrm; // input file
93 
94  SwNumRule* mpStyRule; // bullets and enumerations in styles
95 
96  sal_uInt8* mpParaSprms; // all ParaSprms of the UPX if UPX.Papx
97  sal_uInt16 mnSprmsLen; // its length
98 
99  sal_uInt8 mnWwNumLevel; // for bullets and enumerations in styles
100 
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
109 
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);
114 
115  void Set1StyleDefaults();
116  void Import1Style(sal_uInt16 nNr);
117  void RecursiveReg(sal_uInt16 nNr);
118 
119  void ImportNewFormatStyles();
120  void ScanStyles();
121  void ImportOldFormatStyles();
122 
123  bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle);
124  void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp);
125 
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;
133 };
134 
135 class WW8FlySet: public SfxItemSet
136 {
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  long nWidth, long nHeight);
145 };
146 
147 // Gets filled in WW8TabDesc::MergeCells().
148 // Algorithm must ensure proper row and column order in WW8SelBoxInfo!
150 {
151 private:
152  std::vector<std::vector<SwTableBox*> > m_vRows;
153 
154  WW8SelBoxInfo(WW8SelBoxInfo const&) = delete;
155  WW8SelBoxInfo& operator=(WW8SelBoxInfo const&) = delete;
156 
157 public:
159  short nGroupWidth;
161 
162  WW8SelBoxInfo(short nXCenter, short nWidth)
163  : nGroupXStart( nXCenter ), nGroupWidth( nWidth ), bGroupLocked(false)
164  {}
165 
166  size_t size() const
167  {
168  size_t nResult = 0;
169  for (auto& it : m_vRows)
170  nResult += it.size();
171  return nResult;
172  }
173 
174  size_t rowsCount() const { return m_vRows.size(); }
175 
176  const std::vector<SwTableBox*>& row( size_t nIndex ) { return m_vRows[nIndex]; }
177 
178  void push_back( SwTableBox* pBox )
179  {
180  bool bDone = false;
181  for (auto& iRow : m_vRows)
182  if (iRow[0]->GetUpper() == pBox->GetUpper())
183  {
184  iRow.push_back(pBox);
185  bDone = true;
186  break;
187  }
188  if (!bDone)
189  {
190  const size_t sz = m_vRows.size();
191  m_vRows.resize(sz+1);
192  m_vRows[sz].push_back(pBox);
193  }
194  }
195 };
196 
198 {
199  std::vector<OUString> m_aNumRuleNames;
200  std::unique_ptr<sw::util::RedlineStack> mxOldRedlineStack;
201 
203 
206 
207  std::unique_ptr<SwPosition> m_xTmpPos;
208 
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
214 
215  std::vector<std::unique_ptr<WW8SelBoxInfo>> m_MergeGroups; // list of all cells to be merged
216 
218 
219  short m_nRows;
221  short m_nBands;
222  short m_nMinLeft;
224  short m_nMaxRight;
225  short m_nSwWidth;
228 
229  bool m_bOk;
231  sal_Int16 m_eOri;
232  bool m_bIsBiDi;
233  // 2. common admin info
235  short m_nCurrentBandRow; // SW: row of current band
236  // 3. admin info for writer
238 
239  sal_uInt16 m_nRowsToRepeat;
240 
241  // 4. methods
242 
243  sal_uInt16 GetLogicalWWCol() const;
244  void SetTabBorders( SwTableBox* pBox, short nIdx );
245  void SetTabShades( SwTableBox* pBox, short nWwIdx );
246  void SetTabVertAlign( SwTableBox* pBox, short nWwIdx );
247  void SetTabDirection( SwTableBox* pBox, short nWwIdx );
248  void CalcDefaults();
249  void SetPamInCell(short nWwCol, bool bPam);
250  void InsertCells( short nIns );
251  void AdjustNewBand();
252 
253  WW8SelBoxInfo* FindMergeGroup(short nX1, short nWidth, bool bExact);
254 
255  // single box - maybe used in a merge group
256  // (the merge groups are processed later at once)
257  void UpdateTableMergeGroup(WW8_TCell const & rCell,
258  WW8SelBoxInfo* pActGroup, SwTableBox* pActBox, sal_uInt16 nCol );
259 
260  WW8TabDesc(WW8TabDesc const&) = delete;
261  WW8TabDesc& operator=(WW8TabDesc const&) = delete;
262 
263 public:
264  const SwTable* m_pTable; // table
268  bool IsValidCell(short nCol) const;
269  bool InFirstParaInCell() const;
270 
271  WW8TabDesc( SwWW8ImplReader* pIoClass, WW8_CP nStartCp );
272  bool Ok() const { return m_bOk; }
273  void CreateSwTable();
274  void UseSwTable();
275  void SetSizePosition(SwFrameFormat* pFrameFormat);
276  void TableCellEnd();
277  void MoveOutsideTable();
278  void ParkPaM();
279  void FinishSwTable();
280  void MergeCells();
281  short GetMinLeft() const { return m_nConvertedLeft; }
282  ~WW8TabDesc();
283 
284  const WW8_TCell* GetCurrentWWCell() const { return m_pCurrentWWCell; }
285  short GetCurrentCol() const { return m_nCurrentCol; }
286  // find name of numrule valid for current WW-COL
287  OUString GetNumRuleName() const;
288  void SetNumRuleName( const OUString& rName );
289 
290  sw::util::RedlineStack* getOldRedlineStack() { return mxOldRedlineStack.get(); }
291 };
292 
294 
295 WW8LvlType GetNumType(sal_uInt8 nWwLevelNo);
296 #endif
297 
298 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static constexpr RndStdIds eAnchor
Definition: ww8par2.hxx:57
Marks a position in the document model.
Definition: pam.hxx:35
short m_nPreferredWidth
Definition: ww8par2.hxx:226
short m_nCurrentBandRow
Definition: ww8par2.hxx:235
sal_Int16 nYPos
Definition: ww8par2.hxx:50
void SetTabBorders(SwTableBox *pBox, short nIdx)
Definition: ww8par2.cxx:3028
void CalcDefaults()
Definition: ww8par2.cxx:2121
bool mbBidiChanged
Definition: ww8par2.hxx:108
void MergeCells()
Definition: ww8par2.cxx:2591
sw::util::RedlineStack * getOldRedlineStack()
Definition: ww8par2.hxx:290
void Init(const SwWW8ImplReader &rReader, const SwPaM *pPaM)
Definition: ww8par6.cxx:2210
sal_uInt16 mnSprmsLen
Definition: ww8par2.hxx:97
Definition: doc.hxx:186
css::text::WrapTextMode eSurround
Definition: ww8par2.hxx:63
std::unique_ptr< sw::util::RedlineStack > mxOldRedlineStack
Definition: ww8par2.hxx:200
SfxItemSet aChrSet
Definition: ww8par2.hxx:42
WW8SelBoxInfo & operator=(WW8SelBoxInfo const &)=delete
SwFlyFrameFormat * m_pFlyFormat
Definition: ww8par2.hxx:266
WW8RStyle & operator=(const WW8RStyle &)=delete
void SetTabShades(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3083
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
WW8LvlType
Definition: ww8par2.hxx:293
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:1858
sal_uInt8 nYBind
Definition: ww8par2.hxx:65
bool Ok() const
Definition: ww8par2.hxx:272
SwWW8FltControlStack * pCtrlStck
Definition: ww8par2.hxx:41
void SetTabDirection(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3136
WW8TabBandDesc * m_pActBand
Definition: ww8par2.hxx:205
bool PrepareStyle(SwWW8StyInf &rSI, ww::sti eSti, sal_uInt16 nThisStyle, sal_uInt16 nNextStyle)
Definition: ww8par2.cxx:3815
void ImportOldFormatStyles()
Definition: ww8par2.cxx:4288
sal_Int16 eHAlign
Definition: ww8par2.hxx:61
sal_Int16 nLeMgn
Definition: ww8par2.hxx:51
WW8TabBandDesc * m_pFirstBand
Definition: ww8par2.hxx:204
const SwTableLines * m_pTabLines
Definition: ww8par2.hxx:210
WW8TabDesc & operator=(WW8TabDesc const &)=delete
const SwTable * m_pTable
Definition: ww8par2.hxx:264
short m_nMaxRight
Definition: ww8par2.hxx:224
short GetCurrentCol() const
Definition: ww8par2.hxx:285
SwFlyFrameFormat * pFlyFormat
Definition: ww8par2.hxx:47
WW8TabDesc(WW8TabDesc const &)=delete
void SetPamInCell(short nWwCol, bool bPam)
Definition: ww8par2.cxx:2910
SvStream * mpStStrm
Definition: ww8par2.hxx:92
bool mbCJKFontChanged
Definition: ww8par2.hxx:103
std::vector< std::vector< SwTableBox * > > m_vRows
Definition: ww8par2.hxx:152
SfxItemSet aParSet
Definition: ww8par2.hxx:42
sal_Int16 nHeight
Definition: ww8par2.hxx:53
short m_nBands
Definition: ww8par2.hxx:221
void Insert(const SwPosition &rPos)
Definition: ww8par6.cxx:2254
SwTableBoxes * m_pTabBoxes
Definition: ww8par2.hxx:212
void Import()
Definition: ww8par2.cxx:4504
void MoveOutsideTable()
Definition: ww8par2.cxx:2762
std::unique_ptr< SwWW8FltAnchorStack > xOldAnchorStck
Definition: ww8par2.hxx:84
bool IsValidCell(short nCol) const
Definition: ww8par2.cxx:2888
sal_uInt16 nLineSpace
Definition: ww8par2.hxx:70
void ImportGrupx(short nLen, bool bPara, bool bOdd)
Definition: ww8par2.cxx:3728
short nGroupXStart
Definition: ww8par2.hxx:158
short m_nConvertedLeft
Definition: ww8par2.hxx:223
sal_Int16 nRiMgn
Definition: ww8par2.hxx:51
WW8DupProperties(SwDoc &rDoc, SwWW8FltControlStack *pStack)
Definition: ww8par6.cxx:2228
bool m_bIsBiDi
Definition: ww8par2.hxx:232
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwFrameSize eHeightFix
Definition: ww8par2.hxx:56
void AdjustNewBand()
Definition: ww8par2.cxx:3172
void ImportNewFormatStyles()
Definition: ww8par2.cxx:4495
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:3331
void SetNumRuleName(const OUString &rName)
Definition: ww8par2.cxx:3389
sal_uInt8 * mpParaSprms
Definition: ww8par2.hxx:96
short m_nRows
Definition: ww8par2.hxx:219
bool mbFSizeChanged
Definition: ww8par2.hxx:105
sal_Int16 nWidth
Definition: ww8par2.hxx:53
void FinishSwTable()
Definition: ww8par2.cxx:2769
short m_nDefaultSwCols
Definition: ww8par2.hxx:220
short m_nPercentWidth
Definition: ww8par2.hxx:227
sal_uInt8 nXBind
Definition: ww8par2.hxx:65
WW8SelBoxInfo(WW8SelBoxInfo const &)=delete
sal_uInt16 GetLogicalWWCol() const
Definition: ww8par2.cxx:3366
short nGroupWidth
Definition: ww8par2.hxx:159
void CreateSwTable()
Definition: ww8par2.cxx:2384
sti
Definition: wwstyles.hxx:27
SwFrameSize
Definition: fmtfsize.hxx:35
bool bToggelPos
Definition: ww8par2.hxx:72
const WW8FlySet & operator=(const WW8FlySet &)=delete
SwWW8ImplReader * m_pIo
Definition: ww8par2.hxx:202
SwTableLine * m_pTabLine
Definition: ww8par2.hxx:211
std::unique_ptr< SwPosition > m_xTmpPos
Definition: ww8par2.hxx:207
sal_Int16 m_eOri
Definition: ww8par2.hxx:231
size_t rowsCount() const
Definition: ww8par2.hxx:174
bool mbTextColChanged
Definition: ww8par2.hxx:101
WW8SelBoxInfo(short nXCenter, short nWidth)
Definition: ww8par2.hxx:162
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
size_t size() const
Definition: ww8par2.hxx:166
bool mbFontChanged
Definition: ww8par2.hxx:102
std::vector< std::unique_ptr< WW8SelBoxInfo > > m_MergeGroups
Definition: ww8par2.hxx:215
void ScanStyles()
Definition: ww8par2.cxx:4029
std::vector< OUString > m_aNumRuleNames
Definition: ww8par2.hxx:199
sal_Int32 WW8_CP
Definition: ww8struc.hxx:153
bool mbCTLFontChanged
Definition: ww8par2.hxx:104
std::unique_ptr< SwPosition > xMainTextPos
Definition: ww8par2.hxx:69
bool bGroupLocked
Definition: ww8par2.hxx:160
wwSprmParser maSprmParser
Definition: ww8par2.hxx:90
SprmResult HasParaSprm(sal_uInt16 nId) const
Definition: ww8par2.cxx:3618
bool bAutoWidth
Definition: ww8par2.hxx:71
short ImportUPX(short nLen, bool bPAP, bool bOdd)
Definition: ww8par2.cxx:3684
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
bool m_bClaimLineFormat
Definition: ww8par2.hxx:230
SwTableNode * m_pTableNd
Definition: ww8par2.hxx:209
const std::vector< SwTableBox * > & row(size_t nIndex)
Definition: ww8par2.hxx:176
bool InFirstParaInCell() const
Definition: ww8par2.cxx:2895
unsigned char sal_uInt8
sal_Int16 eVAlign
Definition: ww8par2.hxx:60
short m_nSwWidth
Definition: ww8par2.hxx:225
SwNumRule * mpStyRule
Definition: ww8par2.hxx:94
short GetMinLeft() const
Definition: ww8par2.hxx:281
SfxItemSet m_aItemSet
Definition: ww8par2.hxx:267
wwSprmParser knows how to take a sequence of bytes and split it up into sprms and their arguments ...
Definition: ww8scan.hxx:113
WW8_TCell * m_pCurrentWWCell
Definition: ww8par2.hxx:217
sal_Int16 nXPos
Definition: ww8par2.hxx:50
bool m_bOk
Definition: ww8par2.hxx:229
SwTableBox * m_pTabBox
Definition: ww8par2.hxx:213
void TableCellEnd()
Definition: ww8par2.cxx:3277
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
FIB - the File Information Block.
Definition: ww8scan.hxx:1096
WW8LvlType GetNumType(sal_uInt8 nWwLevelNo)
Definition: ww8par2.cxx:868
void ParkPaM()
Definition: ww8par2.cxx:2727
sal_uInt16 m_nRowsToRepeat
Definition: ww8par2.hxx:239
bool mbFCTLSizeChanged
Definition: ww8par2.hxx:106
sal_Int16 nUpMgn
Definition: ww8par2.hxx:52
SwPosition * m_pParentPos
Definition: ww8par2.hxx:265
void Import1Style(sal_uInt16 nNr)
Definition: ww8par2.cxx:3921
void SetTabVertAlign(SwTableBox *pBox, short nWwIdx)
Definition: ww8par2.cxx:3144
long nNewNetWidth
Definition: ww8par2.hxx:68
void PostStyle(SwWW8StyInf const &rSI, bool bOldNoImp)
Definition: ww8par2.cxx:3897
void ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
Definition: ww8par2.cxx:3651
OUString GetNumRuleName() const
Definition: ww8par2.cxx:3381
RndStdIds
sal_uInt8 mnWwNumLevel
Definition: ww8par2.hxx:99
SwWW8ImplReader * mpIo
Definition: ww8par2.hxx:91
void BoxUpWidth(long nWidth)
Definition: ww8par6.cxx:2112
void SetSizePosition(SwFrameFormat *pFrameFormat)
Definition: ww8par2.cxx:2358
short eHRel
Definition: ww8par2.hxx:58
const WW8_TCell * GetCurrentWWCell() const
Definition: ww8par2.hxx:284
void RecursiveReg(sal_uInt16 nNr)
Definition: ww8par2.cxx:3976
short m_nMinLeft
Definition: ww8par2.hxx:222
sal_Int16 nLoMgn
Definition: ww8par2.hxx:52
void PostProcessStyles()
Definition: ww8par2.cxx:3999
void UseSwTable()
Definition: ww8par2.cxx:2562
SwTableLine * GetUpper()
Definition: swtable.hxx:421
void Set1StyleDefaults()
Definition: ww8par2.cxx:3763
short eVRel
Definition: ww8par2.hxx:59
bool mbWidowsChanged
Definition: ww8par2.hxx:107
short m_nCurrentCol
Definition: ww8par2.hxx:237
void push_back(SwTableBox *pBox)
Definition: ww8par2.hxx:178
WW8SelBoxInfo * FindMergeGroup(short nX1, short nWidth, bool bExact)
Definition: ww8par2.cxx:2835
short m_nCurrentRow
Definition: ww8par2.hxx:234
WW8FlySet(SwWW8ImplReader &rReader, const WW8FlyPara *pFW, const WW8SwFlyPara *pFS, bool bGraf)
Definition: ww8par6.cxx:2121
WW8DupProperties & operator=(const WW8DupProperties &)=delete
void InsertCells(short nIns)
Definition: ww8par2.cxx:3016
WW8RStyle(const WW8RStyle &)=delete
sal_Int16 nNetWidth
Definition: ww8par2.hxx:54